#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],prvo[k];
    for ( int i = 0 ; i < k ; i++)
    {
        posl[i] = -1;
        prvo[i] = -1;
    }
    int x = 0;
    for ( int i = 0 ; i < n; i++)
    {
        cin >> a;
        br[int(a)-'a']++;
        if (prvo[int(a)-'a'] == -1) prvo[int(a)-'a'] = i;
        int m = 10e9;
        for ( int j = 0 ; j < k ; j++) m = min(br[j],m);
        int p = m;
        for ( int j = 0 ; j < k ; j++ )
        {
            if ( p == m && m > 1)
            {
                for ( int l = 0 ; l < k ; l++)
                    if ( posl[l] < prvo[j] )
                    {
                        p--;
                        break;
                    }
            }
        }

        izlaz.push_back(max(p+1,x));
        posl[int(a)-'a'] = i;
        x = p+1;
    }
    for ( int i = 0 ; i < n ; i ++) cout << izlaz[i] << " ";

}