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

int main()
{
    int n, m;
    string s, t, u;

    while( cin >> n )
    {
        s = "I";
        u = "";
        if( !n )
            break;

        for( int i = 0; i < n; i++ )
            s += "OI";

        cin >> m;

        cin >> t;
        
        int cnt = 0, i = 0;
        while( i < m )
        {
            u = t.substr( i, s.size() );
            if( s == u )
                cnt++;
            i++;
        }
        cout << cnt << endl;
    }
    return 0;
}
