Codeforces Round 117 (Div. 2)
D
Common Divisors
Codeforces
1400
原题
← CE →
翻译中…

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 $*s*_{1}$.

翻译中…

The second input line contains a non-empty string $*s*_{2}$.

翻译中…

Lengths of strings $*s*_{1}$ and $*s*_{2}$ are positive and do not exceed $10^{5}$. The strings only consist of lowercase Latin letters.

翻译中…

Output

翻译中…

Print the number of common divisors of strings $*s*_{1}$ and $*s*_{2}$.

翻译中…

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".

翻译中…

样例

Input #1
abcdabcd
abcdabcdabcdabcd
Output #1
2
InputCopy OutputCopy
Input #2
aaa
aa
Output #2
1
InputCopy OutputCopy
题目信息
题号
182D
时间限制
2 s
内存限制
256 MB
标签
暴力
哈希
模拟
数学
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。