Shorten ARC

AtCoder
IDarc140_b
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
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
API Response (JSON)
{
  "problem": {
    "name": "Shorten ARC",
    "description": {
      "content": "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 ($",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc140_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ of length $N$ consisting of `A`,`R`,`C`.\nAs long as $S$ contains three consecutive characters that are `ARC`, you can perform the operation below.\n\n*   In an odd-numbered ($...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments