Start: 2023-09-17 08:00:00

0917日常周赛

End: 2023-09-24 00:00:00
Now  2025-08-11 12:18:04  类型: IOI  状态: Ended 

P1. First ABC
Description

You are given a string S consisting of AB, and CS is guaranteed to contain all of AB, 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 AB, and C have appeared at least once.


Input

The input is given from Standard Input in the following format:

N

S

Output

Print the answer.


Examples

Input

5
ACABB

Output

4

Input

4
CABC

Output

3

Input

30
AABABBBABABBABABCABACAABCBACCA

Output

17
Hint
  • 3N100

  • S is a string of length N consisting of AB, and C.

  • S contains all of AB, and C.


Submit

题目参数
Time Limit 1 second
Memory Limit 128 MB
Submit