#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, k;
   cin >> n >> k;
   vector<char> a(n + 1);
   for(int i = 1; i <= n; i++) {
    cin >> a[i];
   }
   map<char,int> M;
   vector<string> V;
   V.push_back("aa");
   V.push_back("ab");
   V.push_back("ac");
   V.push_back("ba");
   V.push_back("bb");
   V.push_back("bc");
   V.push_back("ca");
   V.push_back("cb");
   V.push_back("cc");
   string c = "";
   for(int i = 1; i <= n; i++) {
    c += a[i];
    M[a[i] - 'a'] += 1;
    int ok = 0;
    for(int j = 0; j < k; j++) {
        if(! M[j]) {
            ok = 1;
        }
    }
    if(ok) {
        cout << 1 << " ";
    }
    else {
        int ok = 0;
        for(auto it : V) {
            int r = 0;
            for(int j = 1; j <= i; j++) {
                for(int q = j + 1; q <= i; q++) {
                    if(a[j] == it[0] && a[q] == it[1]) {
                        r = 1;
                    }
                }
            }
            if(!r) {
                ok = 1;
            }
        }
        if(ok) {
            cout << 2 << " ";
        }
        else {
            cout << 3 << " ";
        }
    }
}
}