#abc311a. A - First ABC

A - First ABC

Score : 100100 points

问题陈述

给定一个包含 ABC 的字符串 SS。保证 SS 中包含所有 ABC

如果从左到右逐个检查 SS 的字符,那么在首次满足以下条件时,需要检查多少个字符?

  • ABC 至少各出现一次。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a string SS consisting of A, B, and C. SS is guaranteed to contain all of A, B, and C.

If the characters of SS 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

  • 3N1003 \leq N \leq 100
  • SS is a string of length NN consisting of A, B, and C.
  • SS contains all of A, B, and C.

Input

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

NN

SS

Output

Print the answer.

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 44.

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

update @ 2024/3/10 08:49:57