// Program 80: Count Vowels and Consonants in Each Word import java.util.*; class WordVowelsConsonants { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine().trim(); if (!s.matches("[A-Z]+( [A-Z]+)*[.?!]")) { System.out.println("INVALID INPUT"); return; } String[] words = s.substring(0, s.length() - 1).split(" "); for (String w : words) { int v = 0, c = 0; for (char ch : w.toCharArray()) { if ("AEIOU".indexOf(ch) >= 0) { v++; } else { c++; } } System.out.println(w + ": VOWELS = " + v + ", CONSONANTS = " + c); } } }