#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,k;
string s;
string ans;
string one(string str){
	string str2 = str;
	reverse(str2.begin(),str2.end());
	str += str2;
	string ans = min(str,str2);
	for(int i=1;i<str2.size();i++){
		string S; S.resize(str2.size());
		rep(j,str2.size()) S[j] = str[i+j];
		ans = min(ans,S);
	}
	return ans;
}
string t;
int main(){
	cin >> n >> k >> s;
	ans = one(s);
	if(k == 1){
		cout << ans << endl;
		return 0;
	}
	string ss = s; reverse(ss.begin(),ss.end());
	t = s+ss;
	char ch = 'z';
	rep(i,n) ch = min(ch,s[i]);
	if(k >= 15){
		string ret = "";
		rep(i,n) ret.pb(ch);
		cout << ret << endl;
		return 0;
	}
	vector<P>vec;
	int cur = 0;
	rep(i,n){
		if(s[i] == ch) cur++;
		else {
			if(cur){
				int a = i-cur, b = i-1;
				if(cur * (1<<(k-1)) >= n){
					string ret = "";
					rep(i,n) ret.pb(ch);
					cout << ret << endl;
					return 0;
				}
				string mk ; mk.resize(n);
				rep(i,cur*(1<<(k-1))) mk[i] = ch;
				int pt = 2*n-2-b;
				int nxt = cur*(1<<(k-1));
				while(nxt < n) {
					mk[nxt++] = t[pt--];
				}
				ans = min(ans,mk);
				cur = 0;
			}
		}
	}
	if(cur){
			int a = n-cur, b = n-1;
			if(cur * (1<<k) >= n){
				string ret = "";
				rep(i,n) ret.pb(ch);
				cout << ret << endl;
				return 0;
			}
			string mk ; mk.resize(n);
			rep(i,cur*(1<<k)) mk[i] = ch;
			int pt = n-cur-1;
			int nxt = cur*(1<<k);
			while(nxt < n) {
				mk[nxt++] = t[pt--];
			}
			ans = min(ans,mk);
			cur = 0;
	}
	cout << ans << endl;
}
	