#arc140b. [arc140_b]Shorten ARC
[arc140_b]Shorten ARC
Problem Statement
You are given a string of length consisting of A
,R
,C
.
As long as contains three consecutive characters that are ARC
, you can perform the operation below.
- In an odd-numbered (-st, -rd, -th, ...) operation, choose in three consecutive characters that are
ARC
, and replace them withR
. - In an even-numbered (-nd, -th, -th, ...) operation, choose in three consecutive characters that are
ARC
, and replace them withAC
.
Find the maximum number of operations that can be performed.
Constraints
- is a string of length consisting of
A
,R
,C
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
6
AARCCC
Sample Output 1
2
You can perform two operations as follows.
AARCCC
→ ARCC
→ ACC
Sample Input 2
5
AAAAA
Sample Output 2
0
does not contain three consecutive characters that are ARC
, so you cannot perform the operation at all.
Sample Input 3
9
ARCARCARC
Sample Output 3
3