//bzoj 1396 识别子串
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define inf 1e9+7
#define ll long long
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=200005;
char s[mxn];
bool bo[mxn]; //有无pre反向边
int n,m,p,q,np,nq,len,tot,root;
int step[mxn],pre[mxn],son[mxn][30];
struct segtree //A:维护min(key[i]),B:维护min(key[i]+i)
{
struct node
{
int l,r,mn; //mn:只用来pushdown
node():mn(inf){}
}t[mxn<<1];
inline void build(int l,int r,int num)
{
t[num].l=l,t[num].r=r;
if(l==r) return;
int mid=l+r>>1;
build(l,mid,num<<1);
build(mid+1,r,num<<1|1);
}
inline void move(int num,int c)
{
t[num].mn=min(t[num].mn,c);
}
inline void pushdown(int num)
{
if(t[num].mn!=inf)
move(num<<1,t[num].mn),move(num<<1|1,t[num].mn);
t[num].mn=inf;
}
inline void change(int num,int L,int R,int c)
{
if(L<=t[num].l && t[num].r<=R)
{
move(num,c);return;
}
pushdown(num);
int mid=t[num].l+t[num].r>>1;
if(L<=mid) change(num<<1,L,R,c);
if(R>mid) change(num<<1|1,L,R,c);
}
inline int query(int num,int pos)
{
if(t[num].l==t[num].r) return t[num].mn;
int mid=t[num].l+t[num].r>>1;
pushdown(num);
if(pos<=mid) return query(num<<1,pos);
else return query(num<<1|1,pos);
}
}A,B;
inline void sam()
{
int i,j;
scanf("%s",s+1);
len=strlen(s+1);
root=tot=np=1;
fo(i,1,len)
{
int c=s[i]-'a'+1;
p=np;
step[np=(++tot)]=step[p]+1;
while(p && !son[p][c])
son[p][c]=np,p=pre[p];
if(!p)
{
pre[np]=root;
continue;
}
q=son[p][c];
if(step[q]==step[p]+1)
pre[np]=q;
else
{
step[nq=(++tot)]=step[p]+1;
memcpy(son[nq],son[q],sizeof son[q]);
pre[nq]=pre[q];
pre[q]=pre[np]=nq;
while(p && son[p][c]==q)
son[p][c]=nq,p=pre[p];
}
}
}
int main()
{
int i,j;
sam();
fo(i,1,tot) bo[pre[i]]=1;
A.build(1,len,1),B.build(1,len,1);
fo(i,1,tot)
if(!bo[i])
{
int l=step[i]-step[pre[i]],r=step[i];
B.change(1,1,l-1,r+1);
A.change(1,l,r,r-l+1);
}
fo(i,1,len)
printf("%d\n",min(A.query(1,i),B.query(1,i)-i));
return 0;
}