Contest Duration: - (local time) (100 minutes) Back to Home
A - First ABC /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 問題文

A, B, C からなる文字列 S が与えられます。SA, B, C を全て含むことが保証されます。

S を左から 1 文字ずつ見ていったときに、はじめて次の条件を満たした状態になるのは、左から何文字目まで見たときですか？

• A, B, C が全て 1 回以上出現している。

### 制約

• 3 \leq N \leq 100
• SA, B, C からなる長さ N の文字列
• SA, B, C を全て含む

### 入力

N
S


### 入力例 1

5
ACABB


### 出力例 1

4


3 文字目以前では条件を満たさないので答えは 4 です。

### 入力例 2

4
CABC


### 出力例 2

3


### 入力例 3

30
AABABBBABABBABABCABACAABCBACCA


### 出力例 3

17


Score : 100 points

### Problem Statement

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


### Sample Input 1

5
ACABB


### Sample 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.

### Sample Input 2

4
CABC


### Sample Output 2

3


In the first three characters from the left, each of A, B, and C appears once, satisfying the condition.

### Sample Input 3

30
AABABBBABABBABABCABACAABCBACCA


### Sample Output 3

17