// ~/.vim/cpp_template.cpp
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>
#define REP(i,a,b) for (int i = a; i < b; i++)
// Type Aliases for 1D and 2D vectors with initialization
#define vi(n, val) vector<int>(n, val) // 1D vector of ints with size n, initialized to val
#define vll(n, val) vector<long long>(n, val) // 1D vector of long longs with size n, initialized to val
#define ll long long
#define vvi(n, m, val) vector<vector<int>>(n, vector<int>(m, val)) // 2D vector of ints (n x m), initialized to val
#define vvll(n, m, val) vector<vector<long long>>(n, vector<long long>(m, val)) // 2D vector of long longs (n x m), initialized to val
#define LL_INF std::numeric_limits<long long int>::max()
#define INF std::numeric_limits<int>::max()
using namespace std;
template <typename T>
void pV(const std::vector<T>& vec, const std::string& label = "Vector") {
std::cout << label << ": [ ";
for (const auto& elem : vec) {
std::cout << elem << " ";
}
std::cout << "]" << std::endl;
}
void dfs(int s, vector<bool> *visited, vector<int> (*adj)[]) {
if ((*visited)[s]) return;
(*visited)[s] = true;
// process node s
for (auto u: (*adj)[s]) {
dfs(u, visited, adj);
}
}
/*
// DEPTH-FRIRST-SEARCH
vector<int> adj[N];
vector<bool> visited(N, false);
int u, v;
for(int i = 0; i < M;i++){
cin >> u >> v;
u--;
v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
*/
vector<long long> dijkstra(int N, int x, vector<vector<pair<int,int>>> *adj){
vector<bool> processed(N, false);
vector<long long> distance(N, LL_INF);
priority_queue<pair<long long,int>> q;
//for (int i = 1; i <= n; i++) distance[i] = INF;
distance[x] = 0;
q.push({0,x});
while (!q.empty()) {
int a = q.top().second; q.pop();
if (processed[a]) continue;
processed[a] = true;
for (auto u : (*adj)[a]) {
int b = u.first, w = u.second;
if (distance[a]+w < distance[b]) {
distance[b] = distance[a]+w;
q.push({-distance[b],b});
}
}
}
return distance;
}
vector<int> z(string s) {
int n = s.size();
vector<int> z(n);
int x = 0, y = 0;
for (int i = 1; i < n; i++) {
z[i] = max(0,min(z[i-x],y-i+1));
while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
x = i; y = i+z[i]; z[i]++;
}
}
return z;
}
/*
DIJKSTRA
//vector<vector<pair<int,int>>> adj(N, vector<pair<int, int>>(N));
*/
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
// Your code starts here
string s;
cin >> s;
vector<int> res = z(s);
cout << res.size() << " ";
REP(i, 1, (int)res.size()){
cout << res[i] << " ";
}
cout << endl;
return 0;
}