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>.
"""
This is the solution of Binyamin Wieder to
Ilais' Weekly Challenge - Week 2.
"""


def main():
    # getting users input string
    s = input()  # commented for benchmark: "<input>\n")

    # commented for benchmark
    # print("<output>")

    # making s all lowercase
    s = s.lower()

    # calculating s string diversity
    num_of_unique_letters = calc_diversity(s)
    print(num_of_unique_letters)

    # calculating diversity count dictionary
    diversity_count_dict = calc_diversity_count_dict(s)

    # find iterating through all diversitys until s diversity
    for i in range(1, num_of_unique_letters + 1):
        # getting number of substrings of s that have a diversity of exactly i.
        res = diversity_count_dict.get(i)
        print(res)

    return 0


def calc_diversity(s: str) -> int:
    """
    The calc_diversity function calculates the diversity of a string.
    String diversity is the amount of unique characters that appear in that string.
    :param s: The string which the diversity is calculated for.
    :return: The diversity of s.
    """
    unique_chars = []

    for char in s:

        # checking if char is not in the unique_chars list
        if not (char in unique_chars):
            unique_chars.append(char)

    return len(unique_chars)


def calc_diversity_count_dict(s: str) -> dict:
    """
    The calc_diversity_count_dict function calculates the amount of substrings of s
    that have a diversity of exactly i and stores them in a dictionary.
    :param s: The string searched.
    :return: A dictionary where the key a diversity value and the value is the
    amount of substrings of s that have a diversity of exactly i.
    """
    diversity_count_dict = {}

    string_len = len(s)

    # loop through all substrings
    for start_i in range(0, string_len + 1):
        for end_i in range(start_i + 1, string_len + 1):

            # calculating diversity of substring
            diversity = calc_diversity(s[start_i:end_i])

            # updating diversity_count_dict
            if diversity in diversity_count_dict:
                diversity_count_dict[diversity] += 1
            else:
                diversity_count_dict[diversity] = 1

    return diversity_count_dict


if __name__ == "__main__":
    main()
