408629: GYM103241 D Abc's (Easy Version)

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Abc's (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Elijah is playing against a computer in a game called 'ABCs', where each side takes turns playing the letter $$$A$$$, $$$B$$$, or $$$C$$$, with the computer going first. Every time Elijah plays a letter, he gets a point if and only if it is a card that the computer has played the most of up until that point (ties included). For example if the computer has played $$$AABC$$$, Elijah will only get a point if he plays $$$A$$$, but if the computer has played $$$ACBBC$$$ then Elijah will get a point whether he plays a $$$B$$$ or a $$$C$$$.

Being the trickster that he is, Elijah hacked into the game and found out the exact order the computer will play the letters. Unfortunately for him, the game found out about this trickery, and decided to punish him by only allowing him to play a single letter every turn (i.e. either all $$$A$$$s, all $$$B$$$s or all $$$C$$$s). Elijah wants to make the best of the situation, and wants to compute to maximum possible of points he can achieve.

Input

The first line contains $$$N (1 \leq N \leq 10^5)$$$, denoting the number of turns. The next line contains a string with $$$N$$$ characters describing what letters the computer will play in the game (as obtained by Elijah's nefarious hacking).

Output

Output the maximum points that Elijah can achieve if he is only allowed to play one letter the entire game.

ExampleInput
9
ABBCCCBAB
Output
7
Note

If Elijah plays all $$$B$$$'s, he will get a point for each turn except for the 1st and 6th one.

Problem idea: Bossologist

Problem preparation: Bossologist

Occurances: Novice 4

加入题单

算法标签: