Strings - 3
(Time limit: 2 sec. Memory limit: 128 MB Difficulty: 60%)
A cyclic shift of a string s is the string sksk+1sk+2 ... s|s| s1s2 ... sk-1 for some k, where |s| is the length of the string s. A substring of the string s is the string sisi+1 ... sj-1sj for some i and j. Given two strings a and b, output the number of substrings of string a which are cyclic shifts of string b.
Input
The first line of the input contains the string a (1 ≤ |a| ≤ 105). The second line of the input contains the string b (1 ≤ |b| ≤ |a|). Both strings consist of letters of the English alphabet and digits only.
Output
Output one integer - the answer to the problem.
Samples
№ | INPUT.TXT | OUTPUT.TXT |
1 | abcabc abc | 4 |
2 | abcabc acb | 0 |
3 | aaaaaaa aa | 6 |
4 | aAaa8aaAa aAa | 4 |
To submit solutions, register and login please.
|