First ABC 2

AtCoder
IDabc322_a
Time2000ms
Memory256MB
Difficulty
You are given a string $S$ of length $N$ consisting of `A`, `B`, and `C`. Find the position where `ABC` first appears as a (contiguous) substring in $S$. In other words, find the smallest integer $n$ that satisfies all of the following conditions. * $1 \leq n \leq N - 2$. * The string obtained by extracting the $n$\-th through $(n+2)$\-th characters of $S$ is `ABC`. If `ABC` does not appear in $S$, print `-1`. ## Constraints * $3 \leq N \leq 100$ * $S$ is a string of length $N$ consisting of `A`, `B`, and `C`. ## Input The input is given from Standard Input in the following format: $N$ $S$ [samples]
Samples
Input #1
8
ABABCABC
Output #1
3

`ABC` first appears in $S$ at the $3$\-rd through $5$\-th characters of $S$. Therefore, the answer is $3$.
Input #2
3
ACB
Output #2
\-1

If `ABC` does not appear in $S$, print $-1$.
Input #3
20
BBAAABBACAACABCBABAB
Output #3
13
API Response (JSON)
{
  "problem": {
    "name": "First ABC 2",
    "description": {
      "content": "You are given a string $S$ of length $N$ consisting of `A`, `B`, and `C`.   Find the position where `ABC` first appears as a (contiguous) substring in $S$. In other words, find the smallest integer $n",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc322_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ of length $N$ consisting of `A`, `B`, and `C`.  \nFind the position where `ABC` first appears as a (contiguous) substring in $S$. In other words, find the smallest integer $n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments