First ABC

AtCoder
IDabc311_a
Time2000ms
Memory256MB
Difficulty
You are given a string $S$ consisting of `A`, `B`, and `C`. $S$ is guaranteed to contain all of `A`, `B`, and `C`. If the characters of $S$ are checked one by one from the left, how many characters will have been checked when the following condition is satisfied for the first time? * All of `A`, `B`, and `C` have appeared at least once. ## Constraints * $3 \leq N \leq 100$ * $S$ is a string of length $N$ consisting of `A`, `B`, and `C`. * $S$ contains all of `A`, `B`, and `C`. ## Input The input is given from Standard Input in the following format: $N$ $S$ [samples]
Samples
Input #1
5
ACABB
Output #1
4

In the first four characters from the left, `A`, `B`, and `C` appear twice, once, and once, respectively, satisfying the condition.  
The condition is not satisfied by checking three or fewer characters, so the answer is $4$.
Input #2
4
CABC
Output #2
3

In the first three characters from the left, each of `A`, `B`, and `C` appears once, satisfying the condition.
Input #3
30
AABABBBABABBABABCABACAABCBACCA
Output #3
17
API Response (JSON)
{
  "problem": {
    "name": "First ABC",
    "description": {
      "content": "You are given a string $S$ consisting of `A`, `B`, and `C`. $S$ is guaranteed to contain all of `A`, `B`, and `C`. If the characters of $S$ are checked one by one from the left, how many characters wi",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc311_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ consisting of `A`, `B`, and `C`. $S$ is guaranteed to contain all of `A`, `B`, and `C`.\nIf the characters of $S$ are checked one by one from the left, how many characters wi...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments