#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int inf = 2147483647;


int n, k;
string s;
int l[26];
int a[26][26];
bitset<26> v, vm;
int p[26];

void fff(char c){
    for(int i = 0; i < k; ++i){
        if(i == c) continue;
        int t = 0;
        for(int j = 0; j < 26; ++j){

            if(a[i][j] < l[j]) ++t;
        }
        if(t == k) ++p[i];
    }
}


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k >> s;
    int br = 0;
    for(int i = 0; i < n; ++i){
        char c = s[i]-'a';
        vm[c] = 0;
        ++l[c];
        if(!v[c]){
            for(int j = 0; j < k; ++j){
                a[c][j] = l[j];
            }
            ++br;
            v[c] = 1;
        }
        if(br != k){
            cout << "1 ";
            continue;
        }
        int t = 0;
        for(int j = 0; j < k; ++j){
            if(l[j]-a[c][j] != 0) ++t;
        }
        fff(c);
        if(t == k){
            ++p[c];
            for(int j = 0; j < k; ++j){
                a[c][j] = l[j];
            }
        }
        else vm[c] = 1;
        int m = inf;
        for(int j = 0; j < k; ++j) m = min(m, p[j]);
        cout << m+2 << ' ';
        /*if(i == 5){
            cout << "\nBREAK\n";
            for(int j = 0; j < k; ++j){
                for(int l = 0; l < k; ++l){
                    cout << a[l][j] << ' ';
                }
                cout << '\n';
            }
            cout << '\n' << i << "p: "; for(int j = 0; j < k; ++j) cout << ' ' << p[j]; cout << '\n';
            cout << '\n' << i << "l: "; for(int j = 0; j < k; ++j) cout << ' ' << l[j]; cout << '\n';
        }*/
    }
    return 0;
}