#include <bits/stdc++.h>

using namespace std;

int const N = 1e4 + 5;


int n, k;

int main() {
	cin >> n >> k;
	string s;
	cin >> s;
	string rev = s;
	reverse(rev.begin(), rev.end());
	s = s + rev;
	char mins = 'z';
	for (char p : s) {
		mins = min(mins, p);
	}

	int ans = 0;
	for (int i = (int)s.size() - 1; i >= n - 1;) {
		if (s[i] != mins) {
			i--;
			continue;
		}
		int pos = i;
		while (pos >= 0 && s[pos] == mins) {
			pos--;
		}
		ans = max(ans, i - pos);
		i = pos;
	}

	int maxLen = ans;
	for (int i = 1; i <= k - 1; i++) {
		maxLen = maxLen * 2;
		if (maxLen >= n) {
			maxLen = n;
			break;
		}
	}

	if (maxLen == n) {
		for (int i = 1; i <= n; i++) {
			cout << mins;
		}
		cout << endl;
		return 0;
	}

	string suffix = "";
	for (int i = (int)s.size() - 1; i >= n - 1;) {
		if (s[i] != mins) {
			i--;
			continue;
		}
		int pos = i;
		while (pos >= 0 && s[pos] == mins) {
			pos--;
		}

		if (i - pos == ans) {
			string cur = s.substr(pos - (n - maxLen) + 1, n - maxLen);
			//cout << i << " " << pos << " " << cur << endl;
			reverse(cur.begin(), cur.end());
			suffix = suffix == "" ? cur : min(cur, suffix);
		}
		i = pos;
	}

	for (int i = 1; i <= maxLen; i++) {
		cout << mins;
	}
	cout << suffix << endl;


}