Problem8746--[CSES Problem Set] Special Substrings

8746: [CSES Problem Set] Special Substrings

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

A substring is called special if every character that appears in the string appears the same number of times in the substring.
Your task is to count the number of special substrings in a given string.

Input

The only input line has a string of length $n$. Every character is between a...z.

Output

Print one integer: the number of special substrings.

Constraints

$1 \leq n \leq 2 \times 10^5$

Sample 1 Input

abccabab

Sample 1 Output

5
The special substrings are abc, cab, abccab, bccaba and ccabab.

HINT

相同题目:CSES 2186

Source/Category