201401: [AtCoder]ARC140 B - Shorten ARC

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

You are given a string $S$ of length $N$ consisting of A,R,C.

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

  • In an odd-numbered ($1$-st, $3$-rd, $5$-th, ...) operation, choose in $S$ three consecutive characters that are ARC, and replace them with R.
  • In an even-numbered ($2$-nd, $4$-th, $6$-th, ...) operation, choose in $S$ three consecutive characters that are ARC, and replace them with AC.

Find the maximum number of operations that can be performed.

Constraints

  • $1 \leq N \leq 2\times 10^5$
  • $S$ is a string of length $N$ consisting of A,R,C.

Input

Input is given from Standard Input in the following format:

$N$
$S$

Output

Print the answer.


Sample Input 1

6
AARCCC

Sample Output 1

2

You can perform two operations as follows.

AARCCCARCCACC


Sample Input 2

5
AAAAA

Sample Output 2

0

$S$ 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

Input

题意翻译

### 题目描述 --- 给出一个仅由 $A,R,C$ 组成的长度为 $n$ $(1\le n\le 2\times 10^5)$ 的字符串 $S$,您可以进行操作: - 如果进行第奇数次操作,您需要用 $R$ 替换一次 $S$ 中的任意一个子串 $ARC$ - 如果进行第偶数次操作,您需要用 $AC$ 替换一次 $S$ 中的任意一个子串 $ARC$ 最多能进行多少次操作? 翻译 by wukaichen888 ### 输入格式 输入共两行,第一行含一个正整数 $n$。 第二行包括一个长度为 $n$ 的字符串 $S$。 ### 输出格式 一行,表示答案。

加入题单

上一题 下一题 算法标签: