Cyclic Rotations

Count the left rotations of binary string B that exactly equal binary string A.

Medium4String matchingInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given two binary strings AA and BB. Count the left cyclic rotations of BB whose bitwise XOR with AA is zero in every position.

For a string P=P0P1PN1P = P_0 P_1 \dots P_{N-1} of length NN, rotating PP left kk times produces the string whose character at position ii is P(i+k)modNP_{(i+k) \bmod N}. The shift amount kk is an integer with 0k<N0 \le k < N, and two shifts with different kk count separately even when they produce the same string.

Input

The first line contains AA and the second line contains BB. Both strings consist of the characters 0 and 1 only and have the same length, which is between 1 and 10510^5.

Output

Print the number of cyclic rotations of BB whose XOR with AA is zero in every position.