QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB

#23971. Aoi and IOI

الإحصائيات

You are given a string $S$ of length $N$. Each character of $S$ is either A, O, or I.

When extracting $3$ consecutive characters contained in $S$, output the number of such substrings that are A, O, I or I, O, I in order.

Constraints

  • $1 \le N \le 100$.
  • $S$ is a string of length $N$.
  • Each character of $S$ is either A, O, or I.
  • $N$ is an integer.

Input

The input is given in the following format:

N
S

Output

Output the sum of the number of occurrences of AOI and the number of occurrences of IOI contained in $S$.

Do not output anything other than the answer. (Do not output prompt sentences or anything similar.)

Examples

Input 1

5
IAOIO

Output 1

1

Note 1

  • The $2$-nd, $3$-rd, and $4$-th characters of $S$ are A, O, and I, respectively.
  • The $3$ characters I, O, I do not appear consecutively in this order in $S$.

The total number of occurrences of AOI and IOI contained in $S$ is $1$. Therefore, output $1$.

Input 2

8
AOIOIOIA

Output 2

3

Note 2

  • The $1$-st, $2$-nd, and $3$-rd characters of $S$ are A, O, and I, respectively.
  • The $3$-rd, $4$-th, and $5$-th characters of $S$ are I, O, and I, respectively.
  • The $5$-th, $6$-th, and $7$-th characters of $S$ are I, O, and I, respectively.

The total number of occurrences of AOI and IOI contained in $S$ is $3$. Therefore, output $3$.

Input 3

6
IIOOII

Output 3

0

Note 3

Neither AOI nor IOI is contained in $S$. Therefore, output $0$.

Input 4

15
IAOIAOAOIOIAIOI

Output 4

4

Note 4

The total number of occurrences of AOI and IOI contained in $S$ is $4$. Therefore, output $4$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.