#include <bits/stdc++.h>
using namespace std;

int br[26];
int main()
{
    int n,k;
    cin >> n >> k;
    char a[n],b[n];
    vector<int>izlaz;
    for ( int i = 0 ; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
        br[int(a[i])-'a']++;
        int m = 200000;
        for ( int j = 0 ; j < k ; j++) m = min(m,br[j]);
        izlaz.push_back(m+1);
    }
    sort(b,b+n);
    bool s = true;
    for ( int i = 0 ; i < n ; i++)
    {
        if ( a[i] != b[i]) s = false;
    }
    if ( s == true)
        for ( int i = 0 ; i < n ; i++ ) cout << 1  << " ";
    else for ( int i = 0 ; i < n ; i ++) cout << izlaz[i] << " ";

}