#include <bits/stdc++.h>
using namespace std;
char s[300010];
int dp[300010][30];
long long ans[27];
int gan(int a, int b) { return a | b; }
int get(int b, int e) {
  int j = 31 - __builtin_clz(e - b + 1);
  return gan(dp[b][j], dp[e - (1 << j) + 1][j]);
}
void build(int n) {
  int i, j;
  for (int j = 1; (1 << j) <= n; j++) {
    for (int i = 1; i + (1 << j) - 1 <= n; i++) {
      dp[i][j] = gan(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
    }
  }
}
int main() {
  while (~scanf("%s", s + 1)) {
    memset(ans, 0, sizeof(ans));
    int len = strlen(s + 1);
    for (int i = 1; i <= len; i++) dp[i][0] = 1 << (s[i] - 'a');
    build(len);
    int maxx = 0;
    for (int i = 1; i <= len; i++) {
      int id = i;
      while (id <= len) {
        int l = id, r = len, g = get(i, id);
        while (l < r) {
          if (l + 1 == r) {
            if (get(i, r) == g) l = r;
            break;
          }
          int m = l + r >> 1;
          if (get(i, m) == g)
            l = m;
          else
            r = m;
        }
        maxx = max(__builtin_popcount(g), maxx);
        ans[__builtin_popcount(g)] += l - id + 1;
        id = l + 1;
      }
    }
    printf("%d\n", maxx);
    for (int i = 1; i <= maxx; i++) printf("%I64d\n", ans[i]);
  }
  return 0;
}
