QOJ.ac

QOJ

时间限制: 2 s 内存限制: 1024 MB

#23971. Aoi e IOI

统计

È data una stringa $S$ di lunghezza $N$. Ogni carattere di $S$ è A, O oppure I.

Prendendo $3$ caratteri consecutivi contenuti in $S$, stampa il numero di tali sottostringhe che sono nell'ordine A, O, I oppure I, O, I.

Vincoli

  • $1 \le N \le 100$.
  • $S$ è una stringa di lunghezza $N$.
  • Ogni carattere di $S$ è A, O oppure I.
  • $N$ è un numero intero.

Input

L'input è fornito nel seguente formato:

N
S

Output

Stampa la somma del numero di AOI e del numero di IOI contenuti in $S$.

Non stampare nient'altro oltre alla risposta. (Non stampare frasi di richiesta input o simili.)

Esempi

Input 1

5
IAOIO

Output 1

1

Nota 1

  • Il $2$-o, $3$-o e $4$-o carattere di $S$ sono rispettivamente A, O e I.
  • I $3$ caratteri I, O, I non compaiono consecutivamente in quest'ordine in $S$.

Il numero totale di AOI e IOI contenuti in $S$ è $1$. Pertanto, si stampa $1$.

Input 2

8
AOIOIOIA

Output 2

3

Nota 2

  • Il $1$-o, $2$-o e $3$-o carattere di $S$ sono rispettivamente A, O e I.
  • Il $3$-o, $4$-o e $5$-o carattere di $S$ sono rispettivamente I, O e I.
  • Il $5$-o, $6$-o e $7$-o carattere di $S$ sono rispettivamente I, O e I.

Il numero totale di AOI e IOI contenuti in $S$ è $3$. Pertanto, si stampa $3$.

Input 3

6
IIOOII

Output 3

0

Nota 3

Né AOI né IOI sono contenuti in $S$. Pertanto, si stampa $0$.

Input 4

15
IAOIAOAOIOIAIOI

Output 4

4

Nota 4

Il numero totale di AOI e IOI contenuti in $S$ è $4$. Pertanto, si stampa $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.