/*****************************************************************
** CountWords - count words enter from keyboard
**
** A more useful source of input is a disk file which may be
** read using input redirection.  A sample dialog is
**
**    PROMPT>java CountWords < CountWords.java
**    118 words read
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;
import java.util.*;

public class CountWords
{
   public static void main(String[] args) throws IOException
   {
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      String line;
      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())
         {
            words.nextToken();
            count++;
         }
      }

      // OK, now print the result
      System.out.println("\n" + count + " words read");
   }
}

