#include<bits/stdc++.h>
using namespace std;
int n, k, pos, len;
string s, t;
int main()
{
	cin >> n >> k >> s;
	if (k > 16 || n <= (1 << (k - 1)))
	{
		cout << string(n, *min_element(s.begin(), s.end())) << endl;
		return 0;
	}
	t = s;
	s = s + string(s.rbegin(), s.rend());
	for (int i = 0; i < n; i++)
		t = min(t, s.substr(i, n));
	while (pos < n && t[pos] == t[0])pos++;
	len = min(n, pos << (k - 1));
	cout << string(len, t[0]) << t.substr(pos, n - len) << endl;
	return 0;
}