#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int n,k, rez;
    vector<string> alfabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    cin >> n >> k;
    for (int i = 0; i < (26-k); i++) {
        alfabet.pop_back();
    }
    vector<string> ram = alfabet;
    string s;
    cin >> s;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < ram.size(); j++) {
                //cout << s[i] << " " << ram[j] << " " << i << " " << j << " " << ram.size() << endl;
            if (s[i] == ram[j].back()) {
                if (ram.size() == 1) {
                    for (int k = 0; k < alfabet.size(); k++) {
                        ram.push_back(ram.front() + alfabet[k]);
                    }
                        ram.erase(ram.begin());
                        rez = ram.front().size();
                        break;
                } else {
                ram.erase(ram.begin()+j);
                j--;
                }
            } else {
                rez = ram[j].size();
                //cout << ram[j].size() << endl;
            }
        }
        cout << rez << ' ';
    }
    return 0;
}