public class Test3 {
public static void main(String[] args) {
String s1 = "ab";
String s2 = "abdkjfabdgjab";
System.out.println(count(s1, s2));
}
public static int count(String s1, String s2) {
int count = 0;
while (s2.indexOf(s1) != -1) {
int begin = s2.indexOf(s1) + s1.length();
s2 = s2.substring(begin);
count++;
}
return count;
}
}