#Lutece0554. Video Game Combos
Video Game Combos
Migrated from Lutece 554 Video Game Combos
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Bessie is playing a video game! In the game, the three letters A
, B
, and C
are the only valid buttons. Bessie may press the buttons in any order she likes; however, there are only distinct combos possible (). Combo is represented as a string which has a length between and and contains only the letters A
, B
, and C
.
Whenever Bessie presses a combination of letters that matches with a combo, she gets one point for the combo. Combos may overlap with each other or even finish at the same time! For example if and the three possible combos are ABA
, CB
, and ABACB
, and Bessie presses ABACB
, she will end with points. Bessie may score points for a single combo more than once.
Bessie of course wants to earn points as quickly as possible. If she presses exactly buttons (), what is the maximum number of points she can earn?
Input
- Line : Two space-separated integers: and .
- Lines : Line contains only the string , representing combo .
Output
- Line : A single integer, the maximum number of points Bessie can obtain.
Samples
3 7
ABA
CB
ABACB
4
Note
The optimal sequence of buttons in this case is ABACBCB
, which gives
points-- from ABA
, from ABACB
, and from CB
.
Resources
USACO Jan 2012