#include <bits/stdc++.h>
using namespace std;
int L;
char s[300005];
int nxt[300005][26];
long long ans[300005];
int main() {
  scanf("%s", s);
  L = strlen(s);
  for (int i = 0; i < 26; ++i) nxt[L][i] = L;
  for (int i = L - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
    nxt[i][s[i] - 'a'] = i;
  }
  memset(ans, 0, sizeof ans);
  int D = 0;
  for (int i = 0; i < L; ++i) {
    int mask = (1 << (s[i] - 'a')), d = 0, pos = i;
    while (pos < L) {
      int e = L;
      for (int j = 0; j < 26; ++j)
        if ((mask & (1 << j)) == 0) e = min(e, nxt[i + 1][j]);
      ans[++d] += e - pos;
      pos = e;
      for (int j = 0; j < 26; ++j)
        if (nxt[i + 1][j] == e) mask |= (1 << j);
    }
    D = max(D, d);
  }
  printf("%d\n", D);
  for (int i = 1; i <= D; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
