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>.
import random as rnd

input = input()
inputDiversity = len(set(input))
diversityList = [0 for i in range(inputDiversity)]

def updateDiversityList(strMaxDiv, lastOcc, subString):
    lastOccurence = lastOcc.copy()
    j = len(subString) - 1
    maxIndex = lastOccurence.pop(subString[j])
    for i in range(strMaxDiv):
        try:
            maxIndex = max(lastOccurence.values())
        except:
            maxIndex = -1
        diversityList[i] += j - maxIndex
        if lastOccurence:
            j = lastOccurence.pop(subString[maxIndex])

lettersSet = set({})
maxDiversity = 0
lastOccurence= dict()
for i in range(len(input)):
    if input[i] not in lettersSet:
        maxDiversity += 1
        lettersSet.add(input[i])
    lastOccurence[input[i]] = i
    updateDiversityList(maxDiversity, lastOccurence, input[:i+1])

print(str(inputDiversity))
for i in range(inputDiversity):
    print(str(diversityList[i]))