#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define cy cout << "YES" << endl;
#define cn cout << "NO" << endl;
#define pf push_front
#define pb push_back
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) cout << x << endl;
#define prints(x) cout << x << ' ';

bool stringSorted(string s)
{
    for(int i = 1; i < s.length(); i++)
    {
        if(s[i] < s[i-1])
            return false;
    }
    return true;
}

void solve()
{
    ll n,k; cin >> n >> k;
    string s; cin >> s;
    vll cntSlova(k,0);


    if(stringSorted(s))
    {
        set <int> st;
        int flag = false;
        cout << '1' << ' ';
        st.insert(s[0]);
        for(int i = 1; i < s.length(); i++)
        {
            st.insert(s[i]);
            if(s[i] != s[i-1])
            {
                flag = true;
            }

            if(!flag || st.size() != k)
                cout << "1" << ' ';
            else
                cout << "2" << ' ';

        }
        return;
    }
    for(ll i = 0; i < s.length(); i++)
    {
        cntSlova[s[i] - 'a']++;

        ll mn = 1e9;
        for(ll j = 0; j < k; j++)
            mn = min(mn, cntSlova[j]);
        cout << mn + 1 << ' ';

    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt= 1;
    while(tt--)
    {
        solve();
    }
}