text of lowercase English letters and an integer times. Call a contiguous non-empty piece of the string even if every letter that occurs in it occurs exactly times times. Letters absent from the piece do not matter.
Count the even pieces of text. Pieces with identical content but different starting positions are counted separately.text='xxyyxy', times=2 → 4
Four pieces qualify: "xx", "yy", "xxyy" and "xyyx". In "yyxy" the letter y appears three times, and in the two-letter "xy" and "yx" each letter appears only once.
text='mmmm', times=2 → 3
The piece "mm" occurs at three positions. The whole string does not count: it has four m's, not two.
text='abcabc', times=2 → 1
text) ≤ 3·10⁴times ≤ 3·10⁴text consists only of lowercase English letterstext='xxyyxy', times=2
4
Run checks the first 3 tests in your browser. Submit checks all 99 tests on the server, hidden ones included.