#include <bits/stdc++.h>
using namespace std;

int br[26];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    char a;
    vector<int>izlaz;
    int posl[k];
    for ( int i = 0 ; i < k ; i++) posl[i] = -1;
    for ( int i = 0 ; i < n; i++)
    {
        cin >> a;
        br[int(a)-'a']++;
        posl[int(a)-'a'] = i;
        int m = 10e9;
        for ( int j = 0 ; j < k ; j++)
        {
            if ( br[j] < m || (br[j] == m && char('a' + j) == a))
            {
                m = br[j];
                if ( m > 1)
                    for ( int l = 0 ; l < j ; l++)
                        if ( posl[l] < posl[j] )
                        {
                            m--;
                            break;
                        }
            }
        }
        izlaz.push_back(m+1);
    }
    for ( int i = 0 ; i < n ; i ++) cout << izlaz[i] << " ";

}