#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 5005
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,k,mx;
char s[N],p;
string ans;
int main(){
	n=read(),k=min(read(),15);
	scanf("%s",s+1);
	p=*min_element(s+1,s+n+1);
	for(int i=1,j=0;i<=n;++i){
		if(s[i]==p)++j;
		else j=0;
		mx=max(mx,j<<(i==n));
	}
	if(mx*(1<<k-1)>=n){
		ans=string(n,p);
		goto End;
	}
	for(int i=1,j=0;i<=n;++i){
		if(s[i]==p)++j;
		else j=0;
		if((j<<(i==n))<mx)continue;
		string tmp="";
		for(int t=1;t<=mx*(1<<k-1);++t){
			tmp+=p;
		}
		int res=n-mx*(1<<k-1);
		for(int t=i+1;t<=n&&res;++t,--res){
			tmp+=s[t];
		}
		for(int t=(i==n?n-j:n);t>=1&&res;--t,--res){
			tmp+=s[t];
		}
		if(ans.empty()||ans>tmp){
			ans=tmp;
		}
	}
	End:
		cout<<ans<<endl;
	return 0;
}

