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)