#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=5005;
int n,K,mn=233,mx;
char s[N],t[N],ans[N];

void doit(int K,int l,int r){
	rep(T,1,K-1){
		rep(i,1,l-1)t[i]=t[i+n-(l-1)];
		reverse(t+l,t+n+1);
		if(r<n)l=n-(r-l),r=n;
		else l=2*l-n-1;
		if(l<=0)return;
	}
	rep(i,l,n)t[i-l+1]=t[i];
	reverse(t+n-l+2,t+n+1);
}

int main(){
	read(n),read(K);
	K=min(K,15);
	scanf("%s",s+1);
	memcpy(ans,s,sizeof s);
	rep(i,1,n)
		mn=min(mn,(int)s[i]);
	for(int l=1,r;l<=n;l++)
		if(s[l]==mn){
			for(r=l;r<n&&s[r+1]==mn;r++);
			if(r-l<mx&&r<n)continue;
			mx=max(mx,r-l);
			memcpy(t,s,sizeof s);
			doit(K,l,r);
			if(strcmp(t+1,ans+1)<0)memcpy(ans,t,sizeof t);
			l=r;
		}
	puts(ans+1);
	return 0;
}