String rotations

Given a string ss of size nn, we define the ii-th rotation of ss (for 0i<n0 \le i < n) as sisi+1sn1s0si2si1.s_i s_{i+1} \dots s_{n-1} s_0 \dots s_{i-2} s_{i-1} \enspace .

Given two strings ss and tt, compute how many ii-th rotations of ss are equal to tt.

For instance, for s=s =abbabb” and t=t =babbab” the answer is 2, corresponding to i=2i = 2 and i=5i = 5.

Input

Input consists of several cases, each one with two strings ss and tt with only lowercase letters. Assume 1|s|=|t|1051 \le \vert s \vert = \vert t \vert \le 10^5. Every letter appears the same number of times in ss and in tt.

Output

For every case, print the number of ii-th rotations of ss that are equal to tt.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:11:45.976Z

© Jutge.org, 2006–2026.
https://jutge.org