import java.util.*;
import java.io.*;

class Dictionary {

    public static void main(String[] args) {
	try {
	    Scanner dictScanner = new Scanner(new File("shaks12.txt"));
	    PrintWriter output = new PrintWriter("output.txt");

	    int count = 0;
	    int totalWordLength = 0;
	    String longest = "";
	    int[] charCounts = new int[26];
	    for (int i = 0; i < 26; i++) {
		charCounts[i] = 0;
	    }

	    while (dictScanner.hasNext()) {
		String word = dictScanner.next();
		count++;
		totalWordLength += word.length();
		if (longest.length() < word.length()) {
		    longest = word;
		}
		for (int i = 0; i < word.length(); i++) {
		    if (Character.isLetter(word.charAt(i))) {
			char letter = Character.toUpperCase(word.charAt(i));
			charCounts[(int)(letter - 'A')]++;
		    }
		}
	    }

	    for (int i = 0; i < 26; i++) {
		output.println("Frequency of " + (char)('A' + i) + " is " 
			       + (1.0 * charCounts[i]) / totalWordLength);
	    }
	    output.println("Number of words = " + count);
	    output.println("Average word length = " 
			   + (1.0*totalWordLength)/count);
	    output.println("Longest word:  " + longest);
	    output.close();
	}
	catch (IOException e) {
	    System.out.println("Sorry, I couldn't find the dictionary.");
	}
    }

}
