#include <bits/stdc++.h>
const int N = 300240, inf = 0x7fffffff;
using namespace std;
char s[N];
long long cnt[N][28], last[26], ans[26];
bool used[26];
int main(void) {
  int n, tot, p;
  while (scanf("%s", s + 1) != EOF) {
    n = strlen(s + 1);
    tot = 0;
    memset(used, 0, sizeof(used));
    for (int i = 1; i <= n; i++) used[s[i] - 'a'] = true;
    for (int i = 0; i < 26; i++)
      if (used[i]) tot++;
    memset(last, 0, sizeof(last));
    memset(ans, 0, sizeof(ans));
    for (int i = n; i; i--) {
      last[s[i] - 'a'] = i;
      for (int j = 0; j < 26; j++) {
        cnt[i][j] = last[j];
      }
    }
    for (int i = 1; i <= n; i++) {
      sort(cnt[i], cnt[i] + 26);
      for (int j = 0; j < 26; j++)
        if (cnt[i][j] == i) {
          p = j;
          break;
        }
      for (int j = p + 1; j < 26; j++) {
        ans[j - p] += cnt[i][j] - cnt[i][j - 1];
      }
      ans[26 - p] += n - cnt[i][25] + 1;
    }
    printf("%d\n", tot);
    for (int i = 1; i <= tot; i++) printf("%I64d\n", ans[i]);
  }
  return 0;
}
