AtCoder Regular Contest 140
B
Shorten ARC
AtCoder
⌀ 1092
原题
← AC →
翻译中…

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.

翻译中…

样例

Input #1
6
AARCCC
Output #1
2
You can perform two operations as follows. `AARCCC` → `ARCC` → `ACC`
Input #2
5
AAAAA
Output #2
0
$S$ does not contain three consecutive characters that are `ARC`, so you cannot perform the operation at all.
Input #3
9
ARCARCARC
Output #3
3
题目信息
题号
arc140_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。