String diversity is the number of symbols that occur in the string at least once. Diversity of *s* will be denoted by *d*(*s*). For example , *d*("aaa")=1, *d*("abacaba")=3.

Given a string *s*, consisting of lowercase Latin letters. Consider all its substrings. Obviously, any substring diversity is a number from 1 to *d*(*s*). Find statistics about substrings diversity: for each *k* from 1 to *d*(*s*), find how many substrings of *s* has a diversity of exactly *k*.
The input consists of a single line containing *s*. It contains only lowercase Latin letters, the length of *s* is from 1 to 3·10<sup class="upper-index">5</sup>.
#include <cstdio>
#include <set>
using namespace std;

char s[300001];
int k, c[128], m;

int main() {
  scanf("%s", s);
  k = set<char>(s, s + 300001).size() - 1;
  printf("%d\n", k);
  for (int i = 1; i <= k; ++i) {
    long long a = 0;
    int j = 0, l = 0;
    for (int z = 0; s[z]; ++z) {
      while (m < i && s[j])
        m += !c[s[j++]]++;
      while (c[s[l]])
        ++l;
      if (m == i)
        a += l - j + 1;
      m -= !--c[s[z]];
    }
    printf("%lld\n", a);
  }
}