atcoder#ARC140B. [ARC140B] Shorten ARC

[ARC140B] Shorten ARC

Score : 400400 points

Problem Statement

You are given a string SS of length NN consisting of A,R,C.

As long as SS contains three consecutive characters that are ARC, you can perform the operation below.

  • In an odd-numbered (11-st, 33-rd, 55-th, ...) operation, choose in SS three consecutive characters that are ARC, and replace them with R.
  • In an even-numbered (22-nd, 44-th, 66-th, ...) operation, choose in SS three consecutive characters that are ARC, and replace them with AC.

Find the maximum number of operations that can be performed.

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • SS is a string of length NN consisting of A,R,C.

Input

Input is given from Standard Input in the following format:

NN

SS

Output

Print the answer.

6
AARCCC
2

You can perform two operations as follows.

AARCCCARCCACC

5
AAAAA
0

SS does not contain three consecutive characters that are ARC, so you cannot perform the operation at all.

9
ARCARCARC
3