40 lines
703 B
C
40 lines
703 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
|
|
bool isIOI(char* str, int index);
|
|
|
|
int main(){
|
|
int N, M;
|
|
scanf("%d %d\n",&N,&M);
|
|
|
|
char* S = (char*)malloc(M+1);
|
|
fgets(S, M+1, stdin);
|
|
|
|
int oiCount = 0, result = 0, i = 0;
|
|
while(i<M-1){
|
|
if(isIOI(S,i)){
|
|
oiCount++;
|
|
i += 2;
|
|
|
|
if(oiCount==N){
|
|
result++;
|
|
oiCount--;
|
|
}
|
|
}
|
|
else{
|
|
oiCount = 0;
|
|
i++;
|
|
}
|
|
|
|
}
|
|
|
|
printf("%d\n",result);
|
|
|
|
free(S);
|
|
return 0;
|
|
}
|
|
|
|
bool isIOI(char* str, int index){
|
|
return (str[index] == 'I' && str[index+1] == 'O' && str[index+2] == 'I') ? true : false;
|
|
} |