#include <bits/stdc++.h>
#define ll long

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    char a[n];
    for(ll i = 0; i < n;i++)
    {
        cin >> a[i];
    }
    ll c[k] = {0};
    for(ll i = 0; i < n;i++)
    {
        c[int(a[i])-97]++;
        ll h = c[0];
        for(ll j = 0; j < k;j++)
        {
            if(h > c[j]) h = c[j];
            if(h > k-1) h = k-1;
        }
        cout << h+1 << " ";
    }
}