/*
KMP 算法的应用
这个题目可以这么理解,算出next[len]之后,那么根据重复字串的性质
它有个必要条件是,len-next[len]的大小就是重复字串的长度,这是个必要条件
如果这个条件不满足的话,那么它必定没有重复字串。
*/
// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <strstream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>
using namespace std;
// typedef
typedef long long LL;
typedef unsigned long long ULL;
//
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
#define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
#define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
#define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
#define FF(i,a) for(int i=0;i<(a);i+++)
#define FFD(i,a) for(int i=(a)-1;i>=0;i--)
#define Z(a) (a<<1)
#define Y(a) (a>>1)
const double eps = 1e-6;
const double INFf = 1e10;
const int INFi = 1000000000;
const double Pi = acos(-1.0);
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
if(x>y) return x;
return y;
}
template<class T> inline T TMIN(T x,T y)
{
if(x<y) return x;
return y;
}
template<class T> inline void SWAP(T &x,T &y)
{
T t = x;
x = y;
y = t;
}
template<class T> inline T MMAX(T x,T y,T z)
{
return TMAX(TMAX(x,y),z);
}
// code begin
#define MAXN 1000010
char P[MAXN];
int next[MAXN];
int Ps;
int ans;
void CalNext()
{
next[0] = 0;
next[1] = 0;
int j;
FORi(2,Ps+1,1)
{
j = next[i-1];
while(true)
{
if( P[j]==P[i-1])
{
next[i] = j+1;
break;
}
if(j==0)
{
next[i] = 0;
break;
}
j = next[j];
}
}
}
int main()
{
read;
write;
while(scanf("%s",P)!=-1)
{
if(P[0]=='.') break;
Ps = strlen(P);
CalNext();
if(Ps%(Ps-next[Ps])==0)
{
printf("%d\n",Ps/(Ps-next[Ps]));
}
else printf("%d\n",1);
}
return 0;
}