#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;





bool nadji(string str, string sub, int duzina)
{
	int len = str.size();
	for (int i = 0; i < len; i++)
	{
		string strsub = str.substr(i, duzina);

		if (strsub == sub)
		{
			return true;
		}

		i += (duzina - 1);

	}

	return false;
}












int main()
{
	int S, K;
	cin >> S >> K;

	string s;

	cin >> s;

	vector <string> pojava(S, "");

	string str = "";

	for (int i = 0; i < S; i++)
	{
		char c = s[i];

		for (int j = i; j >= 0; j--)
		{
			if (j != 0) {

				int nivo_ispod = pojava[j - 1].size();

				int ind = 0;
				while (ind < nivo_ispod)
				{
					string sub = pojava[j - 1].substr(ind, j);

					sub += c;


					if ( !nadji(pojava[j], sub, j + 1))
					{
						pojava[j] += sub;
					}

					ind += j;
				}
			}
			else
			{

				if (pojava[j].find(c) == string::npos)
				{
					pojava[j] += c;
				}
			}


			//--------------------------------------------------------------------------------------------------
			//provera min nepod


			/*for (int p = 0; p <= i; p++)
			{
				int vel = pojava[p].size();
				int maximum = pow(3, p + 1);

				if (vel < maximum) {
					cout << p + 1 << " ";
					break;
				}
			}*/


		}


		for (int p = 0; p <= i; p++)
		{
			int pnivo = pojava[p].size();
			int broj_lv = pnivo / (p + 1);
			int maximum = pow(K, p + 1);

			if (broj_lv < maximum)
			{
				cout << p + 1 << " ";

				break;
			}
		}
	}




	return 0;
}