You have to read the input at once as string and iterate then over the characters of that string.
Assuming that the input is from the console (keyboard) and terminated by pressing the RETURN key, you can read the input with
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
To iterate over items you need knowledge about loops, the class holding the items (
String (Java SE 9 & JDK 9 )[
^]), and which methods of that class might be useful for the problem to be solved.
With strings, this is obviously the length (number of characters) and how to get the character at a specific position in the string.
Because this might be homework and you have no tried anything so far, I will not give you code.
Very important aspects of learning a programming language are trying to do it yourself, reading the official documentation for the language, and reading a good book, tutorials or your course notes.