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


void solve(string s, vector<string> s3, ll rez[]) {
    vector<string> s2;
    vector<ll> r;
    string p="";
    int br=0;
    bool da = false;
    int c=s.length();
    while(c>0) {
        for(int j=0;j<s.length()-c+1;j++) {
            p=p+s[j];
            for(int i=j+1;i<j+c;i++){
                p=p+s[i];
            }

            s2.push_back(p);
            p="";
        }
        c--;
    }
    sort(s2.begin(),s2.end());
    for(int i=0;i<s3.size();i++) {
        for(int j=0;j<s2.size();j++) {
            if(s2[j] == s3[i]) da = true;
        }
        if(!da) r.push_back(s3[i].length());
        da=false;
    }
    sort(r.begin(),r.end());
    rez[s.length()-1] = r[0];
    cout << "\n";
}

main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s="",p="",rs="";
    ll n,k;
    vector<string> s2;
    vector<string> s3;
    cin>> n;
    cin >> k;
    cin >> s;
    ll rez[n];
    ll a=97;
    int i=0;
    int c=s.length();
    for(int i=s.length()-1;i>-1;i--) {
        rs=rs+s[i];
    }
     string x="";
    for(int i=0;i<k;i++) {
        x=x+char(a);
        s3.push_back(x);
        x="";
        a++;
    }

    while(c>0) {
        for(int j=0;j<s.length()-c+1;j++) {
            p=p+s[j];
            for(int i=j+1;i<j+c;i++){
                p=p+s[i];
            }
            s3.push_back(p);
            s2.push_back(p);
            p="";
        }
        c--;
    }
    c=rs.length();
    while(c>0) {
        for(int j=0;j<rs.length()-c+1;j++) {
            p=p+rs[j];
            for(int i=j+1;i<j+c;i++){
                p=p+rs[i];
            }
            s3.push_back(p);
            p="";
        }
        c--;
    }

    sort(s2.begin(),s2.end());
    sort(s3.begin(),s3.end());
    /*for(int i=0;i<s2.size();i++) {
        cout << s2[i] << " ";
    }
    cout << "\n";
    for(int i=0;i<s3.size();i++) {
        cout << s3[i] << " ";
    }*/
    for(int i=0;i<n;i++) {
        p=p+s[i];
        solve(p,s3,rez);
    }
    for(int i=0;i<n;i++) {
        cout << rez[i]<< " ";
    }
    return 0;
}