#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int M = 30;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  vector<long long> ans(M), pre(M, -1);
  set<int> pos{-1}, diff;
  for (int i = 0; i < s.size(); i++) {
    int c = s[i] - 'a';
    diff.insert(c);
    if (pre[c] != -1) {
      pos.erase(pre[c]);
    }
    pre[c] = i;
    pos.insert(pre[c]);
    int j = 0, p, sz = pos.size();
    for (int x : pos) {
      if (j > 0) {
        ans[sz - j] += x - p;
      }
      p = x;
      j++;
    }
  }
  cout << diff.size() << "\n";
  for (int i = 1; i <= diff.size(); i++) {
    cout << ans[i] << " ";
  }
}
