import java.io.*;
import java.util.*;

public class SimpleWordCount {
    public static void main(String[] args) throws FileNotFoundException
    {
        Scanner in = new Scanner(new File("data/test.txt"));
	    //in.useDelimiter("\\Z");
        //String text = in.next();
       // String[] words = text.split("\\s+");
	   // System.out.println("Total # words = " + words.length);
        
        // another way to do the above
        String[] words = new String[500];  // limited in size
        int count = 0;
        while (in.hasNext() && count < 500)
        {
        	words[count] = in.next(); // gets one word at a time
        	count++;
        }
        System.out.println("Total # words = " + count);
        for (int k = 0; k < count; k = k + 1) {
            System.out.println(words[k]);
        }
            
    }
}
