#include<cstdio> #include<cstring> using namespace std; // KMP next数组的用法 const int Maxn = 1e6; char str[Maxn+5]; int next[Maxn+5]; int len; void get_next() { int i = 0,j=-1; next[i] = -1; while(i<len) { if(j==-1||str[i]==str[j]) { ++i; ++j; next[i] = j; } else j = next[j]; } } int main() { int k; while(gets(str)&&str[0]!='.') { len = strlen(str); get_next(); k = len%(len-next[len]); printf("%d\n",k=k?1:len/(len-next[len])); } return 0; }