#include <bits/stdc++.h>

#define int long long

#define pb push_back

#define F first

#define S second

const int N = 2e5 + 10;

const int inf = 2e9;

using namespace std;

bool have(string s,string t) {
//dal imam t u s
    reverse(t.begin(),t.end());
    for(auto X : s) {
        if(!t.empty() && X == t.back()) t.pop_back();
    }
    return t.empty();
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s = '.' + s;
    vector<int>cnt(26,0);
    queue<string>q,qq;
    for(int j = 0; j < k; j++) {
        char x = 'a' + j;
        string ss;
        ss += x;
        q.push(ss);
    }
    while(!q.empty()) {
        string tt = q.front();
        qq.push(tt);
        q.pop();
        if(tt.size() > 3) break;
        for(int j = 0; j < k; j++) {
            string ttt = tt;
            char c = j + 'a';
            ttt += c;
            q.push(ttt);
        }
    }
    string prefix;
    for(int i = 1; i <= n; i++) {
        prefix += s[i];
        cnt[s[i] - 'a'] += 1;
        int mn = inf;
        for(int j = 0; j < k; j++) mn = min(mn,cnt[j]);
        if(!mn) {
            cout << 1 << " ";
            continue;
        }
        q = qq;
        while(q.size()) {
            if(!have(prefix,q.front())) {
                cout << (int)q.front().size() << " ";
                goto kraj;
            }
            q.pop();
        }
        kraj:;
    }
    return 0;
}