/* IMPORTANT: Multiple classes and nested static classes are supported */
import java.io.BufferedReader;
import java.io.InputStreamReader;
class TestClass {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
String[] strs = line.trim().split("\\s+");
int size = Integer.parseInt(strs[0]);
int suvoCount = 0;
int suvojitCount = 0;
//read each line
for (int i = 0; i < size; i++) {
line = br.readLine();
strs = line.trim().split("\\s+");
for (int j = 0; j < strs[0].length(); j++) {
if ( strs[0].substring(j).startsWith("SUVOJIT")) {
suvojitCount++;
} else if (strs[0].substring(j).startsWith("SUVO")) {
suvoCount++;
}
}
System.out.println("SUVO = " + suvoCount + ", SUVOJIT = " + suvojitCount);
suvoCount = 0; suvojitCount = 0;
}
}
}
Language: Java 8