#P6120. Hoof, Scissors, Cloth
Hoof, Scissors, Cloth
Hoof, Scissors, Cloth
This problem is based on a variant of the famous game "Rock, Paper, Scissors", played with the moves Hoof, Scissors, and Cloth. The rules are as follows:
- Hoof beats Scissors.
- Scissors beats Cloth.
- Cloth beats Hoof.
- If both players use the same move, the round is a tie.
FJ and Bassie will play \(N\) rounds. Bassie already knows FJ's moves in advance. However, Bassie is lazy and is only willing to change her move at most once throughout the game. In other words, she may choose one move for the first several rounds and possibly switch to a different move for the remaining rounds (or not switch at all).
Your task is to help Bassie determine the maximum number of rounds she can win.
inputFormat
The first line contains a single integer \(N\) (the number of rounds). The next \(N\) lines each contain a single character, representing FJ's predicted move in that round. Each move is one of the following:
- H for Hoof
- S for Scissors
- C for Cloth
outputFormat
Output a single integer representing the maximum number of rounds Bassie can win if she is allowed to change moves at most once.
sample
3
H
S
C
2