Programmer's school

Forgot password?
[problems] [status] [courses] [info] [register]
Login:   Password:    

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.TXTOUTPUT.TXT
1abcabc
abc
4
2abcabc
acb
0
3aaaaaaa
aa
6
4aAaa8aaAa
aAa
4

To submit solutions, register and login please.


Krasnoyarsk regional Palace of pioneers, (c)2006 - 2025, ИНН 246305493507, E-mail: admin@acmp.ru