#P9043. [PA 2021] Zbalansowane słowa
[PA 2021] Zbalansowane słowa
Problem Description
A string is defined to be good if and only if all characters contained in it appear the same number of times.
Examples of good strings: mama, aabbcbcccbaa.
Examples of bad strings: ovo.
Given a string , find the number of good substrings of .
Input Format
One line containing a string .
Output Format
One line containing an integer, representing the required value.
aabbabcccba
28
Hint
For of the testdata, , and contains only the three lowercase letters a, b, c.
Translated by ChatGPT 5