#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    char c[n];
    string s;
    int k = 0;
    cin >> k;
    char abeceda[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for (int i = 0; i < k; i++)
    {
        c[i] = abeceda[i];
    }

    cin >> s;

    int niz_a[n];
    int niz_b[n];
    int broja = 0;
    int brojb = 0;

    bool pre_a = false, posle_a = false;

    if (k == 2 && n <= 5)
    {
        for (int i = 0; i < n; i++)
        {
            if (i == 0)
            {
                if (s[i] == 'a')
                {
                    broja++;
                    cout << 1 << " ";
                }
                else
                {
                    brojb++;
                    cout << 1 << " ";
                }
                continue;
            }

            if (s[i] == 'a')
            {
                broja++;
                if (s[i - 1] == 'b')
                {
                    pre_a = true;
                }

                if (!pre_a && !posle_a)
                {
                    cout << 1 << " ";
                }
                else if ((pre_a && !posle_a) || (!pre_a && posle_a))
                {
                    cout << 2 << " ";
                }
                else
                {
                    cout << min(broja, brojb) + 1 << " ";
                }

            }
            else
            {
                brojb++;
                if (s[i - 1] == 'a')
                {
                    posle_a = true;
                }

                if (!pre_a && !posle_a)
                {
                    cout << 1 << " ";
                }
                else if ((pre_a && !posle_a) || (!pre_a && posle_a))
                {
                    cout << 2 << " ";
                }
                else
                {
                    cout << min(broja, brojb) + 1 << " ";
                }
            }
        }


    }



    return 0;
}