import java.util.Scanner;
public class JavaApplication61 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input String:");
String text = scan.nextLine();
text = text.toLowerCase();
char c = ' ', prevC = ' ';
int count = 0;
for (int i = 0; i < text.length(); i++){
c = text.charAt(i);
if (c == 'h' && prevC == 's' && i >= 1){
count += 1;
}
prevC = c;
}
System.out.println("Contains \"sh\" "+count+" times.");
}
}
This works for me. Best of luck.