#include <bits/stdc++.h>

using namespace std;

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

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

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

    vector<int> freq(k, 0);
    for(int i = 0; i < n; ++i)
    {
        freq[id(s[i])]++;
        int min_freq = 1e6;
        for(int j = 0; j < k; ++j) min_freq = min(min_freq, freq[id(s[j])]);
        cout << min_freq + 1 << " ";
    }
    cout << "\n";
}