while 1:

    n=int(eval(input()))

    if n==0:break

    a='I'+'OI'*n

    b,s,c=int(eval(input())),eval(input()),0

    for i in range(b-len(a)):

        if s[i:i+len(a)]==a:c+=1

    print(c)
while 1:

    n=int(eval(input()))

    if n==0:break

    a='I'+'OI'*n

    b,s=int(eval(input())),eval(input())

    print((sum(1 for i in range(b-len(a)) if s[i:i+len(a)]==a)))
while 1:
    n = int(eval(input()))
    if n == 0:
        break
    a = "I" + "OI" * n
    b, s, c = int(eval(input())), eval(input()), 0
    for i in range(b - len(a)):
        if s[i : i + len(a)] == a:
            c += 1
    print(c)

while 1:
    n = int(eval(input()))
    if n == 0:
        break
    a = "I" + "OI" * n
    b, s = int(eval(input())), eval(input())
    print((sum(1 for i in range(b - len(a)) if s[i : i + len(a)] == a)))

-    b, s, c = int(eval(input())), eval(input()), 0 -    for i in range(b - len(a)): -        if s[i : i + len(a)] == a: -            c += 1 -    print(c) +    b, s = int(eval(input())), eval(input()) +    print((sum(1 for i in range(b - len(a)) if s[i : i + len(a)] == a)))