-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
28 lines (22 loc) · 706 Bytes
/
Main.java
File metadata and controls
28 lines (22 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String docu = br.readLine();
String word = br.readLine();
int idx = 0;
int result = 0;
while (docu.length() - idx >= word.length()) {
if (docu.substring(idx, idx + word.length()).equals(word)) {
idx += word.length();
result++;
} else {
idx++;
}
}
System.out.println(result);
br.close();
}
}