Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with.

String a is the divisor of string b if and only if there exists a positive integer x such that if we write out string a consecutively x times, we get string b. For example, string "abab" has two divisors — "ab" and "abab".

Now Vasya wants to write a program that calculates the number of common divisors of two strings. Please help him.

Input

The first input line contains a non-empty string s1.

The second input line contains a non-empty string s2.

Lengths of strings s1 and s2 are positive and do not exceed 105. The strings only consist of lowercase Latin letters.

Output

Print the number of common divisors of strings s1 and s2. 

Examples

Input

abcdabcd
abcdabcdabcdabcd


Output

2


Input

aaa
aa


Output

1

Note

In first sample the common divisors are strings "abcd" and "abcdabcd".

In the second sample the common divisor is a single string "a". String "aa" isn't included in the answer as it isn't a divisor of string "aaa".
import bisect
def gcd(a,b):
    c = a % b;
    return gcd(b,c) if c else b
def computeLPSArray(pat):
    length = 0  # lengthgth of the previous longest prefix suffix
    M = len(pat)
    lps =[0] * M # lps[0] is always 0
    i = 1
    # the loop calculates lps[i] for i = 1 to M-1
    while i < M:
        if pat[i] == pat[length]:
            length += 1
            lps[i] = length
            i += 1
        else:
            # This is tricky. Consider the example.
            # AAACAAAA and i = 7. The idea is similar
            # to search step.
            if length != 0:
                length = lps[length - 1]

                # Also, note that we do not increment i here
            else:
                lps[i] = 0
                i += 1
    return lps

a = input()
b = input()
lps_a = computeLPSArray(a)
lps_b = computeLPSArray(b)
last_a = lps_a[-1]
last_b = lps_b[-1]
# print(lps_a,lps_b)
if last_a > last_b:
    curr_a = curr_b = len(a) - last_a
elif last_b > last_a:
    curr_a = curr_b = len(b) - last_b
else:
    curr_a = len(a) - last_a
    if len(a) % curr_a != 0:
        curr_a = len(a)
    curr_b = len(b) - last_b
    if len(b) % curr_b != 0:
        curr_b = len(b)
c = 0
if  a[:curr_a] == b[:curr_b] and lps_a[curr_a:] == list(range(1,len(a) - curr_a+1)) and lps_b[curr_b:] == list(range(1,len(b) -curr_b+1)):
        lena = len(a)
        lenb = len(b)
        if lena % curr_a == 0 and lenb % curr_b == 0:
            da = lena // curr_a
            db  = lenb // curr_b
            if db > da:
                da,db = db,da
            g = gcd(da,db)
            gs = int(g**0.5)
            for i in range(1,gs + 1):
                if g % i == 0:
                    c += 2;
            if g == gs * gs:
                c -= 1;
print(c)



