import java.io.*;
import java.util.*;
public class CountWords {
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("hamlet.txt"));
//Scanner input = new Scanner("hamlet.txt");
//Scanner input = new Scanner("To be, or not to be, that is the question:");
int count = 0;
while (input.hasNext()) {
String word = input.next();
count++;
}
input.close();
System.out.println("total words = " + count);
}
}