Max has been procrastinating on his English summative and needs help finishing it.
Since Max knows his teacher loves alliterations, he would also love when two consecutive characters are the same in a string.
Max has written most of which are gibberish but needs you to clean it up for him to maximize his summative mark.
A string can be derived from these
The score of a string is determined by the number of two-letter substrings that only use one character.
This score determines his summative mark.
Can you help Max find out his maximum summative mark?
Constraints
Note that
Subtask 1 [20%]
Subtask 2 [40%]
Subtask 3 [40%]
No additional constraints.
Input Specification
The first line will contain an integer,
The next
Output Specification
Output the maximum score (i.e., the maximum number of two-letter substrings that only use one character from a subsequence of the
Sample Input
5
ro
r
oo
yo
oort
Sample Output
4
Explanation for Sample Output
If the first, third, fourth, and fifth words are concatenated, the final string is roooyooort
, and there are
Comments