#include <bits/stdc++.h>
using namespace std;
long long n,k, mat[30][200007],sol,niz[30],mini;
vector <int> ind[33];
string a,srt;
long long najm(int x){
    sol=1e9;
    for (int i=1;i<=k;i++){
        if (mat[i][x]!=mat[i][n]){
            sol=min(sol, mat[i][x]+1);
        }
    }




    return 1;

}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    cin >> a;
    srt=a;
    sort(srt.begin(),srt.end());
    if (srt==a){
        for (int i=0;i<n;i++){
            if (srt[i]=='a'){
                cout << 1 << " ";
            }
            else{
                cout << 2 << " ";
            }
        }
        cout << endl;
        return 0;
    }
    a=' '+a;
    for (int i=1;i<=n;i++){
        mat[a[i]-'a'+1][i]++;
        ind[a[i]-'a'+1].push_back(i);
        for (int j=1;j<=k;j++){
            mat[j][i]+=mat[j][i-1];
        }
    }
    for (int i=1;i<=n;i++){
        niz[a[i]-'a'+1]++; // a=1;b=2,...
        mini=1e9;
        for (int j=1;j<=k;j++){
            mini=min(mini, niz[j]);
        }

    cout << mini+1<< " ";
    }
    cout << '\n';

    return 0;
}