#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28
typedef pair<int,int> Pi;
#define F first
#define S second
#define pb push_back

inline void chmax(int &a, int b) { a = max(a,b); }
inline void chmin(int &a, int b) { a = min(a,b); }

int main()
{
  int N, M;
  while(cin >> N, N) {
    string s;
    cin >> M >> s;
    int cnt = -1, sum = 0;
    char save = 'N';
    Rep(i,M) {
      if(save != s[i] && ~cnt) {
	cnt++;
	if(cnt >= N * 2 + 1 && cnt % 2 == 1)sum++;
      }else cnt = -1;
      if(s[i] == 'I')chmax(cnt,1);
      save = s[i];
    }
    cout << sum << endl;
  }
  return 0;
}