#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];
   }
   vector<int> M(k, 0);
   vector<int> M1(k , 0);
   vector<int> M2(k, 0);
   for(int i = 1; i <= n; i++) {
    M[a[i] - 'a'] += 1;
    if(!M1[a[i] - 'a']) {
        M1[a[i] - 'a'] = i;
    }
    else {
        M2[a[i] - 'a'] = i;
    }
    int ok = 0;
    for(int j = 0; j < k; j++) {
        if(!M[j]) {
            ok = 1;
        }
    }
    if(ok) {
        cout << 1 << " ";
    }
    else {
        ok = 0;
        for(int j = 0; j < k; j++) {
            for(int q = 0; q < k; q++) {
                if(M2[j] < M1[q]) {
                    ok = 1;
                }
            }
        }
        if(ok) {
            cout << 2 << " ";
        }
        else {
            cout << 3 << " ";
        }
    }
   }
}