Description

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

Input

Each test case is a line of input representing s, a string of printable characters. The length of s will be at least 1 and will not exceed 1 million characters. A line containing a period follows the last test case.

Output

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

Sample Input

`abcdaaaaababab.`

Sample Output

`143`

```#include

#include

#define max 1000001using namespace std;int next[max];char str[max];int getnext(char *str){
int i=0,j=-1;
int len=strlen(str);
next[0]=-1;
while(i

{
if(j==-1||str[i]==str[j])
{
i++;
j++;
next[i]=j;
}
else
j=next[j];
}
i=len-j;
if(len%i==0)
return len/i;
else
return 1;}int main(){
while(cin>>str)
{
if(str[0]=='.')break;
int ans=getnext(str);
cout<

<

}
return 0;}

```

#### 最新留言

[***.249.68.14]2022年05月24日 17时57分17秒

## 关于作者

喝酒易醉，品茶养心，人生如梦，品茶悟道，何以解忧？唯有杜康！
-- 愿君每日到此一游！