/*****************************************************************
** CountWords3 - same as CountWords2, except using a function
**
** The isAlphaWord() function receives a String as an argument
** and returns a boolean variable.  The boolen variable is returned
** as true if the String contains only alpha characters (a-z,
** A-Z).  It is returned false, otherwise.
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;
import java.util.*;

public class CountWords3
{
   public static void main(String[] args) throws IOException
   {
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      String line;
      String word;
      StringTokenizer words;
      int count = 0;

      // process lines until no more input
      while ((line = stdin.readLine()) != null)
      {
         // process words in line
         words = new StringTokenizer(line);
         while (words.hasMoreTokens())
         {
            word = words.nextToken();
            if (isAlphaWord(word))
               count++;
         }
      }
      System.out.println("\n" + count + " alpha words read");
   }

   public static boolean isAlphaWord(String w)
   {
      for (int i = 0; i < w.length(); i++)
      {
         String c = w.substring(i, i + 1).toUpperCase();
         if (c.compareTo("A") < 0 || c.compareTo("Z") > 0)
            return false;
      }
      return true;
   }
}

