#include <cstdlib> #include <iostream> #include <vector> #include <string> using namespace std; int KMP(const string &pat) { int patLen = pat.size(); int i = 0, j = -1; vector<int> next; next.push_back(-1); while(i < patLen) { if(j == -1 || pat[i] == pat[j]) { i++; j++; if(pat[i] != pat[j]) next.push_back(j); else next.push_back(next[j]); } else j = next[j]; } if(patLen % (patLen - next[patLen]) == 0) return patLen / (patLen - next[patLen]); else return 1; } int main(int argc, char *argv[]) { string input; //freopen("input.txt", "rt", stdin); //freopen("output.txt", "wt", stdout); while(cin >> input, input != ".") { int count = KMP(input); cout << count << endl; } return EXIT_SUCCESS; }