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

using namespace std;

const int INF = 1e6;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    auto id = [&](char c) -> int {
        return (int)(c - 'a');
    };

    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<vector<int>> freq(n + 1, vector<int>(27, 0));
    vector<int> l(27, -1);
    for(int i = 0; i < n; ++i) {
        if(l[id(s[i])] == -1) {
            l[id(s[i])] = i;
        }
    }

    for(int i = 1; i <= n; ++i)
    {
        for(char c = 'a'; c < 'a' + k; ++c)
        {
            freq[i][id(c)] = freq[i - 1][id(c)] + (c == s[i - 1]? 1 : 0);
        }
    }

    auto min_interval = [&](int l, int r) -> int {
        int res = INF;
        for(char c = 'a'; c < 'a' + k; ++c)
        {
            res = min(res, freq[r][id(c)] - freq[l - 1][id(c)]);
        }
        return 2 + res;
    };

    for(int i = 0; i < n; ++i)
    {
        int min_freq = INF;
        for(char c = 'a'; c < 'a' + k; ++c)
        {
            if(l[id(c)] > i || l[id(c)] == -1) {
                min_freq = 1;
                continue;
            }
            min_freq = min(min_freq, min_interval(l[id(c)] + 2, i + 1));
        }
        cout << min_freq << " ";
    }
}