atcoder#ARC140B. [ARC140B] Shorten ARC
[ARC140B] Shorten ARC
Score : points
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.
6
AARCCC
2
You can perform two operations as follows.
AARCCC
→ ARCC
→ ACC
5
AAAAA
0
does not contain three consecutive characters that are ARC
, so you cannot perform the operation at all.
9
ARCARCARC
3