#include <iostream>
#include <cstring>
using namespace std;
int main(){
int zf[1000000];
char s[1000000];
scanf("%[^\n]%*c", s);
int n = strlen(s);
int right=0,left=0;
for(int i=1; i < n; ++i){
if(i<=right){
zf[i]=min(right-i+1,zf[i-left]);
}
while(s[zf[i]]==s[zf[i]+i]){
zf[i]++;
}
if(i+zf[i]-1>right){
left=i;
right=i+zf[i]-1;
}
}
for(int i=0; i < n; ++i){
cout << zf[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4gCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKIAppbnQgbWFpbigpewoJaW50IHpmWzEwMDAwMDBdOwoJY2hhciBzWzEwMDAwMDBdOwogICAgc2NhbmYoIiVbXlxuXSUqYyIsIHMpOwogICAgaW50IG4gPSBzdHJsZW4ocyk7CiAgICBpbnQgcmlnaHQ9MCxsZWZ0PTA7CiAKICAgIGZvcihpbnQgaT0xOyBpIDwgbjsgKytpKXsKICAgICAgICAgICAKICAgICAgICAgICAgaWYoaTw9cmlnaHQpewogICAgICAgIAkJemZbaV09bWluKHJpZ2h0LWkrMSx6ZltpLWxlZnRdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB3aGlsZShzW3pmW2ldXT09c1t6ZltpXStpXSl7CiAgICAgICAgICAgIAl6ZltpXSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKGkremZbaV0tMT5yaWdodCl7CiAgICAJICAgICAgICBsZWZ0PWk7CiAgICAgICAgICAgICAgICByaWdodD1pK3pmW2ldLTE7CiAgICAgICAgICAgIH0KICAgIH0KIAkKICAgIGZvcihpbnQgaT0wOyBpIDwgbjsgKytpKXsKICAgIAljb3V0IDw8IHpmW2ldIDw8ICIgIjsJCiAgICB9CiAgICAKCXJldHVybiAwOyAKfQ==