#K51177. Count Substring Occurrences
Count Substring Occurrences
Count Substring Occurrences
Given two strings S and P, determine the number of times that the substring P occurs in S, including overlapping occurrences. For example, if S is "ababa" and P is "aba", then the answer is 2 because "aba" appears twice (with one occurrence overlapping the other).
The problem requires reading the input from standard input and writing the output to standard output.
Examples:
- Input:
ababa
andaba
→ Output:2
- Input:
aaaaa
andaa
→ Output:4
- Input:
abcdef
andgh
→ Output:0
inputFormat
The input consists of two lines:
- The first line contains the string S.
- The second line contains the string P.
outputFormat
Output a single integer representing the number of times the substring P appears in S (including overlapping occurrences).
## sampleababa
aba
2