#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 10;
int n, nxt[30][MAX], a[MAX];
long long ans[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  s = "X" + s;
  for (int i = 1; i <= n; i++) a[i] = (s[i] - 'a' + 1);
  for (int i = 1; i <= 26; i++) nxt[i][n + 1] = n + 1;
  for (int i = n; i; i--) {
    for (int j = 1; j <= 26; j++) {
      nxt[j][i] = (a[i] == j ? i : nxt[j][i + 1]);
    }
  }
  for (int i = 1; i <= n; i++) {
    vector<int> v;
    for (int j = 1; j <= 26; j++) v.push_back(nxt[j][i]);
    v.push_back(n + 1);
    sort(v.begin(), v.end());
    for (int j = 1; j <= 26; j++) ans[j] += v[j] - v[j - 1];
  }
  int cnt = 26;
  while (!ans[cnt]) cnt--;
  cout << cnt << "\n";
  for (int i = 1; i <= cnt; i++) cout << ans[i] << "\n";
  return 0;
}
