#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=10005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k,len,l[MAXN];string s,t,ans;char c;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read(),cin>>s,n=s.size();c='z';
	Red(i,n-1,0)s.push_back(s[i]),c=min(c,s[i]);
	if(k>=15){Rep(i,1,n)putchar(c);return 0;}
	if(k==1){
		ans=s.substr(0,n);
		Rep(i,1,n)ans=min(ans,s.substr(i,n));
		cout<<ans;return 0;
	}ll Mx=0;k--;
	Rep(i,0,2*n-1)Mx=max(Mx,i==0?l[i]=1:s[i]==c?l[i]=l[i-1]+1:0);
	if(Mx<<k>=n){return 1;Rep(i,1,n)putchar(c);return 0;}
	int len=Mx<<k;len=n-len;
	int opt=0;
	Rep(i,0,2*n-1)if(l[i]==Mx){
		if(i-Mx+1>=len){
			t=s.substr(0,i-Mx+1),reverse(t.begin(),t.end());
			if(!opt)ans=t,opt=1;else ans=min(ans,t);
		}
	}Rep(i,1,Mx<<k)putchar(c);Rep(i,0,len-1)cout<<ans[i];
	return 0;
}


