#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
char s[N];
int n;
vector<int> occ[256];
long long ans[N];
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) occ[(int)s[i]].push_back(i);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int p = i, nx;
    priority_queue<int> q;
    for (int c = 'a'; c <= 'z'; c++) {
      auto it = lower_bound(occ[c].begin(), occ[c].end(), p);
      if (it == occ[c].end()) continue;
      q.emplace(-*it);
    }
    int cnt = 0;
    while (!q.empty()) {
      nx = -q.top();
      q.pop();
      ans[cnt] += nx - p;
      p = nx;
      cnt++;
    }
    ans[cnt] += n - p;
    mx = max(mx, cnt);
  }
  printf("%d\n", mx);
  for (int i = 1; i <= mx; i++) printf("%lld\n", ans[i]);
}
