#include<iostream>
#include<string>
using namespace std;
int main()
{
	while(true)
	{
		int ans=0,chains=0;
		int n,m;
		string s;
		cin>>n;
		if(n==0)break;
		cin>>m>>s;
		for(int i=1;i<m-1;++i){
			if(s[i]=='O'){
				if(s[i-1]!='O'&&s[i+1]!='O'){
					++chains;
					++i;
					continue;
				}
			}
			if(chains >= n)
				ans += chains - n + 1;
			chains=0;
		}
		if(chains >= n)
			ans += chains - n + 1;
		cout<<ans<<endl;
	}
	return 0;
}