You are playing a game of "Double-O-Seven" with your friend. In the game, both players start with an ammo count and a score of
R
Reload: The player increases their ammo count by .F
Fire:If the player's ammo count is
, firing does nothing.If the player's ammo count is greater than
, then:- Decrease the player's ammo count by
. - Decrease the opponent's score by
. - Increase the player's score by
.
- Decrease the player's ammo count by
B
Block: Restrict both players' score from increasing or decreasing this round.
Your friend is so confident that he could beat you, that he will tell you all his actions beforehand. What is the maximum score you could get, knowing your opponent's actions?
Constraints
Points Awarded | Additional Constraints | |
---|---|---|
2 points | The opponent never fires | |
3 points | None | |
10 points | None |
Input Specification
The first line contains a single integer
The second line contains a string of length RFB
. The
Output Specification
Output the maximum possible score you can obtain if you played optimally.
Sample Input 1
3
RFF
Sample Output 1
1
Explanation for Sample Output 1
A possible sequence of actions that obtains this score is RBF
.
On the first round, both players reload and have an ammo count of
On the second round, your friend fires and decreases their ammo count to
On the third round, your friend does nothing as they fired with an ammo count of
Sample Input 2
9
RBFFFBRRF
Sample Output 2
3
Explanation for Sample Output 2
A possible sequence of actions that obtains this score is RRBFFRFFB
.
Comments