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

void function(map<char, int> m, map<char, int> k, vector<char> c, int n, map<char, int> p, int K){
	for(int i = 0; i < n; i++){
		map<char, bool> o;
		/*for(int j = 0; j < n; j++){
			o[c[j]] = false;
		}*/
		int r = 1;
		for(int j = k[c[i]]; j < p[c[i]]; j++){
		if(o[c[j]] == false){
			r++;
		}
		o[c[j]] = true;
		}
		if(r == K){
			cout<<"3 ";
			K = -1;
			break;
		}
	}
	if(K != -1){
		cout<<"4 ";
	}
}
int main(){
	int N, K;
	cin>>N>>K;
	vector<char> c(N);
	map<char, int> m;
	map<char, int> k;
	map<char, int> p;
	for(int i = 0; i < N; i++){
		cin>>c[i];
		m[c[i]] = 0;
		k[c[i]] = -1;
		p[c[i]] = -1;
	}
	int r = K;
	int q = 0;
	for(int i = 0; i < N; i++){
		if(m[c[i]] == 0){
			r--;
		}
		if(k[c[i]] == -1){
		k[c[i]] = i;
	}
	else{
		p[c[i]] = i;
		q++;
	}
		if(r > 0){
			cout<<"1 ";
		}
		else
		if(q < K){
			cout<<"2 ";
		}
		else{
			function(m, k, c, N, p, K);
		}
		m[c[i]] += 1;
	}
}