#include <bits/stdc++.h>
using namespace std;
string greedy(string s, int k){
	if (k == 0) return s;
	int n = s.size();
	while (k > 1){
		int take = 1;
		while (take < n && s[n-take-1] == s[n-1]) take++;
		string t = "";
		for (int i=0; i < n-take;i++) t += s[take+i];
		for (int i=0; i < take; i++) t += s[n-i-1];
		s = t;
		k--;
	}
	int take = 1;
	while (take < n && s[n-take-1] == s[n-1]) take++;
	string t = "";
	for (int i=0; i < take;i++) t += s[n-take+i];
	for (int i=0; i < n-take; i++) t += s[n-i-1];
	return t;
}
signed main() {
	#ifdef LOCAL
		freopen("H_input.txt", "r", stdin);
		//freopen("C_output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    k = min(k, 15);
    string res = "";
    for (int i=0; i < n; i++) res += 'z';
    string t = s;
	reverse(t.begin(), t.end());
	s += t;
	for (int i=0; i <= n; i++){
		string var = "";
		for (int j=0; j < n; j++) var += s[i+j];
		res = min(res, greedy(var, k-1));
	}
	cout << res;
}