N+1개의 I와 N개의 O로 이루어져 있으면, I와 O이 교대로 나오는 문자열을 PN이라고 한다.
I와 O로만 이루어진 문자열 S와 정수 N이 주어졌을 때, S안에 PN이 몇 군데 포함되어 있는지 구하는 프로그램을 작성하시오.
첫째 줄에 N이 주어진다. 둘째 줄에는 S의 길이 M이 주어지며, 셋째 줄에 S가 주어진다.
S에 PN이 몇 군데 포함되어 있는지 출력한다.
n = int(input())
m = int(input())
s = input()
# pn의 길이는 2n+1
cnt = 0
for i in range(m -(2*n+1)+1):
check = True
if s[i] == 'I':
if not i % 2:
for j in range(i, i+2*n+1):
if (not j % 2 and s[j] == 'I') or (j % 2 and s[j] =='O'):
pass
else:
check = False
break
if check:
cnt += 1
else:
for j in range(i, i+2*n+1):
if (not j % 2 and s[j] == 'O') or (j % 2 and s[j] =='I'):
pass
else:
check = False
break
if check:
cnt += 1
print(cnt)
n = int(input())
m = int(input())
s = input()
cnt = 0
check = 0
i = 0
while i < m-2:
if s[i] == 'I' and s[i+1] == 'O' and s[i+2] == 'I':
check += 1
i += 1
if check == n:
check -= 1
cnt += 1
else:
check = 0
i += 1
print(cnt)