#include <bits/stdc++.h>
using namespace std;
const int N = 300004;
char s[N];
int nxt[N][26], head[44];
long long d[44];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 0; i < 26; i++) head[i] = n + 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 26; j++) nxt[i][j] = head[j];
    head[s[i] - 'a'] = i;
  }
  for (int i = 1; i <= n; i++) {
    int v = 1 << (s[i] - 'a');
    for (int j = i, k = 1; j <= n; k++) {
      int mn = n + 1, p = 0;
      for (int c = 0; c < 26; c++) {
        if (v >> c & 1) continue;
        if (nxt[j][c] < mn) {
          mn = nxt[j][c];
          p = c;
        }
      }
      d[k] += mn - j;
      j = mn;
      v |= 1 << p;
    }
  }
  int w = 0;
  for (int i = 1; i <= 26; i++)
    if (d[i]) w = i;
  printf("%d\n", w);
  for (int i = 1; i <= w; i++) printf("%lld\n", d[i]);
}
