#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 1, sigma = 26;
int len[maxn], link[maxn], to[maxn][sigma];
int slink[maxn], diff[maxn], series_ans[maxn];
int sz, last, n;
char s[maxn];
void init()
{
s[n++] = -1;
link[0] = 1;
len[1] = -1;
sz = 2;
}
int get_link(int v)
{
while(s[n - len[v] - 2] != s[n - 1]) v = link[v];
return v;
}
void add_letter(char c)
{
s[n++] = c -= 'a';
last = get_link(last);
if(!to[last][c])
{
len[sz] = len[last] + 2;
link[sz] = to[get_link(link[last])][c];
diff[sz] = len[sz] - len[link[sz]];
if(diff[sz] == diff[link[sz]])
slink[sz] = slink[link[sz]];
else
slink[sz] = link[sz];
to[last][c] = sz++;
}
last = to[last][c];
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
string s;
cin >> s;
int n = s.size();
int ans[n + 1];
memset(ans, 63, sizeof(ans));
ans[0] = 0;
for(int i = 1; i <= n; i++)
{
add_letter(s[i - 1]);
for(int v = last; len[v] > 0; v = slink[v])
{
series_ans[v] = ans[i - (len[slink[v]] + diff[v])];
if(diff[v] == diff[link[v]])
series_ans[v] = min(series_ans[v], series_ans[link[v]]);
ans[i] = min(ans[i], series_ans[v] + 1);
}
cout << ans[i] << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG1heG4gPSAzZTUgKyAxLCBzaWdtYSA9IDI2OwppbnQgbGVuW21heG5dLCBsaW5rW21heG5dLCB0b1ttYXhuXVtzaWdtYV07CmludCBzbGlua1ttYXhuXSwgZGlmZlttYXhuXSwgc2VyaWVzX2Fuc1ttYXhuXTsKaW50IHN6LCBsYXN0LCBuOwpjaGFyIHNbbWF4bl07Cgp2b2lkIGluaXQoKQp7CiAgICBzW24rK10gPSAtMTsKICAgIGxpbmtbMF0gPSAxOwogICAgbGVuWzFdID0gLTE7CiAgICBzeiA9IDI7Cn0KCmludCBnZ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