#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n, k; cin >> n >> k;
    string s; cin >> s;

    ll niz[26] = {0};
    vector<vector<ll>> v(26, vector<ll>(26));
    for (ll i = 0; i < n; i++)
    {
        if (niz[s[i]-'a'] == 0)
        {
            niz[s[i] - 'a'] = 1;
            bool found = false;
            for (ll j = 0; j < k; j++)
                if (niz[j] == 0)
                    found = true;
            if (found)
            {
                cout << 1 << " ";
                for (ll j = 0; j < k; j++)
                {
                    if (niz[j] && j != i)
                    {
                        v[j][s[i]-'a']++;
                    }
                }
            } else
            {
                for (ll j = 0; j < k; j++)
                {
                    if (niz[j] && j != i)
                    {
                        v[j][s[i]-'a']++;
                    }
                }
                ll mn = INT_MAX;
                for (ll p = 0; p < k; p++)
                {
                    for (int q = 0; q < k; q++)
                        mn = min(mn, v[p][q]);
                }
                bool found = false;
                for (ll j = 0; j < k; j++)
                    if (niz[j] == 0)
                        found = true;
                if (found) cout << 1 << " ";
                else cout << mn + 2 << " ";
                }

        } else
        {
            for (int j = 0; j < k; j++)
            {
                if (niz[j])
                {
                    v[j][s[i]-'a']++;
                }
            }
            ll mn = INT_MAX;
            for (ll p = 0; p < k; p++)
                {
                    for (int q = 0; q < k; q++)
                        mn = min(mn, v[p][q]);
                }
            bool found = false;
                for (int j = 0; j < k; j++)
                    if (niz[j] == 0)
                        found = true;
                if (found) cout << 1 << " ";
                else cout << mn + 2 << " ";
        }
    }
}