#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int n,m,length,count,tmp_length;
	char* buf = new char[1000050],pre,start;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		length = 2*n+1;

		scanf("%d",&m);
		scanf("%s",buf);

		count = 0;
		tmp_length = 1;
		pre = buf[0];
		start = buf[0];
		for(int i = 1; i < m; ){
			if(buf[i] != pre){
				tmp_length++;
				pre = buf[i];
				i++;
			}
			else{
				if(start == 'O')tmp_length--;
				if(tmp_length%2==0)tmp_length--;

				if(tmp_length >= length){
					count += (tmp_length-length)/2+1;
				}

				tmp_length = 1;
				pre = buf[i];
				start = buf[i];
				i++;
			}
		}

		printf("%d\n",count);
	}


    return 0;
}