2025-08-04 23:07:18 +09:00

19 lines
339 B
Python

import sys
input = sys.stdin.readline
N, M, S = int(input()), int(input()), input().rstrip()
result = OIcount = i = 0
while i < M-1:
if S[i:i+3] == "IOI":
OIcount += 1
i += 2
if OIcount == N:
result += 1
OIcount -= 1
else:
OIcount = 0
i += 1
print(result)