cswork / OAOpen practice workspace

SnowflakeOA #32

Maximum Substrings

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyStrings

Replace every dot with a letter from a..z to maximize the number of contiguous substrings whose characters are all the same. Substrings of length 1 also count, and fixed characters cannot be changed.

Input

One line containing the color string, of length 1..5000, where each character is a..z or a dot (.). Output the exact integer.

Output

Output the single integer required by the problem.

Example 1

Input:

a.b

Output:

4

Example 2

Input:

...

Output:

6

Example 3

Input:

aa..b

Output:

11

Example notes

The answers to the three public examples are, in order: 4; 6; 11. The examples were rechecked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…