Hide

Problem D
Power Strings

Given two strings a and b we define ab to be their concatenation. For example, if a="abc" and b="def" then ab="abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a0="" (the empty string) and an+1=aan.

Input

The input consists of up to 10 test cases. Each test case is a line of input containing s, a string of lower case letters (a-z). The length of s will be at least 1 and will not exceed 2000000 characters. A line containing a period follows the last test case.

Output

For each s you should print the largest n such that s=an for some string a.

Sample Input 1 Sample Output 1
abcd
aaaa
ababab
.
1
4
3
Hide

Please log in to submit a solution to this problem

Log in