#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
typedef long long LL;
const LL P = 1e9+7;
const int N = 10005;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

char s[N];
int n, k, cont[N];

int main(){
	cin>>n>>k;
	cin>>(s+1);
	char a = 'z';
	rep(i,1,n) a = min(a, s[i]);
	rep(i,1,n) s[n*2+1-i] = s[i];
	
	int l = 0;
	cont[0] = 0;
	rep(i,1,2*n){
		cont[i] = s[i]==a ? cont[i-1] + 1 : 0;
		l = max(l, cont[i]);
	}
	
	string ans="";
	if(l>(n>>k-1)){
		rep(i,1,n)ans+=a;
		cout<<ans<<endl;
		return 0;
	}
	ans += (a+1);
	rep(i,n,2*n)if(cont[i]==l){
		string tmp="";
		int l1 = min(l<<k-1, n), beg, end;
		end = i - l, beg = end - (n - l1) + 1;
		rep(j,1,l1) tmp += a;
		if(end) rrep(j,end,beg) tmp += s[j];
		ans = min(ans, tmp);
	}
	cout<<ans<<endl;
	return 0;
}