Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ String nextLine = scanner.nextLine(); char[] charArray = nextLine.toCharArray(); int count = 0; for (char c:charArray ) { if(c>= 'A' && c <= 'Z'){
                    count++;
                }
            } System.out.println(count);
        }
    }
}