#include <bits/stdc++.h>

using namespace std;

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

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

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

        } else
        {
            for (int j = 0; j < k; j++)
            {
                if (niz[j])
                {
                    v[j][s[i]-'a']++;
                }
            }
            int mn = INT_MAX;
            for (int p = 0; p < k; p++)
            {
                mn = min(mn, *min_element(v[p].begin(), v[p].begin() + k));
            }
            cout << mn + 2 << endl;
        }
    }
}