#include <bits/stdc++.h>
#pragma comment(linker, "/stack:30000000")
using namespace std;
const int mx[4] = {1, -1, 0, 0};
const int my[4] = {0, 0, 1, -1};
const int Direct[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
const int Nmax = 330000;
int right1[Nmax][30];
long long dp[Nmax][30];
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  getline(cin, s);
  int n = s.size();
  s = '#' + s;
  for (int i = 0; i < 26; i++) right1[n][i] = n + 1;
  right1[n][s[n] - 'a'] = n;
  for (int i = n - 1; i >= 1; i--)
    for (char ch = 'a'; ch <= 'z'; ch++) {
      right1[i][ch - 'a'] = right1[i + 1][ch - 'a'];
      if (s[i] == ch) right1[i][ch - 'a'] = i;
    }
  int answer = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    vector<int> list;
    for (int j = 0; j < 26; j++)
      if (right1[i][j] < n + 1) cnt++, list.push_back(right1[i][j]);
    sort(list.begin(), list.end());
    if (list.size() == 0) continue;
    int it = list.size() - 1;
    int position = n;
    answer = max(answer, cnt);
    while (cnt) {
      dp[i][cnt] += position - list[it] + 1;
      position = list[it--] - 1;
      cnt--;
    }
  }
  cout << answer << endl;
  for (int i = 1; i <= answer; i++)
    for (int j = 2; j <= n; j++) dp[1][i] += dp[j][i];
  for (int i = 1; i <= answer; i++) cout << dp[1][i] << endl;
  return 0;
}
