#include <bits/stdc++.h>
using namespace std;
int Top[30], hs[30], g[30], n, ls;
long long Ans[30];
char A[300000 + 3];
int main() {
  scanf("%s", A + 1);
  n = strlen(A + 1);
  for (int i = n; i >= 1; i--) {
    int x = A[i] - 'a';
    if (Top[x]) {
      for (int j = hs[x]; j < ls; j++) g[j] = g[j + 1], hs[g[j]] = j;
      ls--;
    }
    Top[x] = i;
    g[++ls] = x;
    hs[x] = ls;
    for (int j = ls; j > 1; j--) Ans[ls - j + 1] += Top[g[j - 1]] - Top[g[j]];
    Ans[ls] += n - Top[g[1]] + 1;
  }
  printf("%d\n", ls);
  for (int i = 1; Ans[i]; i++) printf("%I64d\n", Ans[i]);
}
