#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    bool vanja128 = true;
    int brrr = 1;
    vector<int> plsradi(k,0);
    vector<int> slova(k,0);
    for(int i = 0; i < n; i++){
        slova[s[i]-'a']++;
        for(int j = 0; j < k; j++){
            if(slova[j] == plsradi[j]){
                    vanja128 = true;
                    break;
            }
        }
        if(vanja128) cout << brrr<< " ";
        else{
            brrr++;
            cout << brrr << " ";
            for(int j = 0; j < k; j++){
                plsradi[j] = slova[j];
            }
        }
        vanja128 = false;


    }
    return 0;
}