#include<iostream>
#include<string>
using namespace std;

int main() {
	int n, m, ans;
	char c[3] = "IO";
	string s;
	while(1) {
		cin >> n;
		if(!n) break;
		cin >> m >> s;
		ans = 0;
		for(int i=0, p=0; i<m; ++i) {
			if(c[p%2]==s[i]) {
				p++;
				if(p%2&&p>=2*n+1) {
					ans++;
				}
			}else p=(c[0]==s[i]?1:0);
		}
		cout << ans << endl;
	}
	return 0;
}