#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<string> s;
    vector<int>izlaz;
    s.push_back("");
    for ( int i = 0 ; i < n; i++)
    {
        cin >> a;
        int x = s.size();
        for ( int j = 0 ; j < x ; j++)
        {
            if (s[j].size()<(n/k) + 1)
            {
                bool b = false;
                for ( int l = 0 ; l < s.size() ; l++)
                    if (s[j] + a == s[l])
                    {
                        b = true;
                        break;
                    }
                if(!b)
                {
                    s.push_back(s[j]+a);
                    int x = (s[j]+a).size();
                    br[x]++;
                }
            }

        }
        for ( int j = 1 ; j < n/k + 2 ; j++)
        {
            if ( br[j] != pow(k,j))
            {
                izlaz.push_back(j);
                break;
            }
        }

    }
    for ( int i = 0 ; i < n ; i ++) cout << izlaz[i] << " ";

}