#K57237. Counting Homogeneous Substrings

    ID: 30376 Type: Default 1000ms 256MiB

Counting Homogeneous Substrings

Counting Homogeneous Substrings

Given a string S consisting of lowercase English letters, determine the total number of substrings such that all characters in each substring are identical. In other words, for every maximal block of identical characters of length n, the number of homogeneous substrings contributed is given by the formula \( \frac{n(n+1)}{2} \).

Input Constraints: The string may be empty or non-empty and will only contain lowercase English letters.

Example 1:

Input: ababa
Output: 5

Example 2:

Input: aaaa
Output: 10

Your task is to implement a program that reads the input from standard input (stdin) and writes the result to standard output (stdout).

inputFormat

The input consists of a single line containing the string S.

outputFormat

Output a single integer which is the total number of substrings of S where all characters are the same.

## sample
ababa
5