#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
int n,m;char a[5010];
char c,ans[5010],s[5010];
void ck(){
	ref(i,1,n)if(s[i]<ans[i])break;else if(s[i]>ans[i])return;
	ref(i,1,n)ans[i]=s[i];
}
void work(int x){
	int nn=0;
	ref(i,x,n)s[++nn]=a[i];
	def(i,n,n-x+2)s[++nn]=a[i];
	int ct=0,lct=0;
	ref(i,1,n)if(s[i]==c){
		ct++;
	}else break;
	lct=ct;
	int mm=m;
	while(ct<n&&mm>0)ct*=2,mm--;
	if(ct>n)ct=n;
	def(i,n-ct,1)s[i+ct]=s[i+lct];
	ref(i,1,ct)s[i]=c;
	ck();
}
int main(){
	scanf("%d%d",&n,&m);m--;
	scanf("%s",a+1);
	ref(i,1,n)ans[i]=a[i];
	c=a[1];
	ref(i,1,n)if(a[i]<c)c=a[i];
	ref(i,1,n)if(a[i]==c)if(i==1||a[i]!=a[i-1])
		work(i);
	ref(i,1,n)cout<<ans[i];cout<<endl;
}