cswork / OAOpen practice workspace

AmazonOA #159

Find Maximum Maxima Count

Estimated EasyJudge-ready

Topics (AI-labelled)HashingStrings

For each non-empty prefix of the original string, every character whose count reaches the maximum count in that prefix gets 1, including all tied characters. Find the maximum accumulated count of a single character.

Input

One line with a lowercase string, 1≤length≤100000.

Output

Output a single integer answer.

Example 1

Input:

bccaaacb

Output:

6

Example 2

Input:

zzzz

Output:

4

Example 3

Input:

ab

Output:

2

Example notes

Example 1: c is tied for or holds the maximum in prefixes 2, 3, 4, 5, 7 and 8, 6 times in total. Example 2: z is the maximum in all 4 prefixes, so the answer is 4. Example 3: a is the maximum in both a and ab, while b is the maximum only in ab, so the answer is 2.

Editorial

Loading solution…