A. [Atc322A] First ABC 2

    传统题 1000ms 256MiB

[Atc322A] First ABC 2

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

You are given a string S of length N consisting of the characters A, B, and C. Your task is to find the position where the substring "ABC" first appears in S. In other words, find the smallest integer n that satisfies the following conditions:

  • (1nN2)(1 \leq n \leq N - 2)
  • The substring from the nn-th character to the (n+2)(n+2)-th character of S is "ABC".

If "ABC" does not appear in S, print -1.

Input

The input consists of:

  • An integer N (3N100)(3 \leq N \leq 100) — the length of the string S.
  • A string S of length N consisting of the characters A, B, and C.

Output

Print the position where the substring "ABC" first appears in S, or -1 if it does not appear.

Examples

Example 1

8
ABABCABC
3

ABC first appears in SS at the 33-rd through 55-th characters of SS. Therefore, the answer is 33.

Example 2

3
ACB
-1

If ABC does not appear in SS, print 1−1.

Example 3

20
BBAAABBACAACABCBABAB
13

Programming exercise on 13 August

未参加
状态
已结束
规则
IOI
题目
3
开始于
2024-8-13 16:30
结束于
2024-8-13 18:30
持续时间
2 小时
主持人
参赛人数
3