public class Solution { public static void main(String[] args) { try (FileReader fileName = new FileReader(args[0])) { int count = 0; Character [] alphabet = {'a', 'b', 'c', 'd', 'i', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; ArrayList<Character> alphabetList = new ArrayList<>(Arrays.asList(alphabet)); Set<Character> readFile = new HashSet<>(); while (fileName.ready()) { readFile.add((char) fileName.read()); } for (char letter : readFile) { if (alphabetList.contains(Character.toLowerCase(letter))) { count++; } } System.out.println(count); } catch (IOException e) { e.printStackTrace(); } } }