#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define FAST ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);

#define ff(i,a,b) for(int (i) = (a);(i)<(b);(i)++)
#define fff(i,a,b) for(int (i) = (a);(i)<=(b);(i)++)
#define bff(i,a,b) for(int (i) = (a);(i)>(b);(i)++)
#define bfff(i,a,b) for(int (i) = (a);(i)>=(b);(i)++)

#define pb push_back
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long int lli;

int main()
{
    FAST
    int n; cin>>n;
    int k; cin>>k;
    int counter['a'+ k+2];
    memset(counter,0,sizeof(counter));
    char curr,before = ' ';
    ff(i,0,n){
        cin>>curr;
        counter[(int)curr]++;
        int minimum = INT_MAX;
        ff(i,(int)'a',(int)'a'+k){
            if(minimum>counter[i]){
                minimum = counter[i];
            }
        }
        cout<<minimum+1<<endl;
    }
    return 0;
}