#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a),ed_##i=(b);i<=ed_##i;++i)
	#define ROF(i,a,b) for(register int i=(a),ed_##i=(b);i>=ed_##i;--i)
	#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a),*ed_##i=(arr)+(b)+1;i!=ed_##i;++i)
	#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(a),*ed_##i=(arr)+(b)-1;i!=ed_##i;--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(x,v) memset(x,v,sizeof(x))
	#define fir first
	#define sec second
	#define pq priority_queue
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	typedef pair<int,int> PII;
	#define Templ(T) template<typename T>
	inline int read(){
		reg int ans=0,f=1; reg char c=getchar();
		while(!isdigit(c)) f^=(c=='-'), c=getchar();
		for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48);
		return f?ans:-ans;
	}
	Templ(_Tp) inline int chkmin(_Tp &x,_Tp y){ return x>y?x=y,1:0; }
	Templ(_Tp) inline int chkmax(_Tp &x,_Tp y){ return x<y?x=y,1:0; }
	#define using_mod
	const int mod = 998244353;
	#ifdef using_mod
	inline void inc(int &x, const int &y){ x += y; if(x >= mod) x -= mod; }
	inline void dec(int &x, const int &y){ x -= y; if(x < 0) x += mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
	#endif
	Templ(_Tp) inline _Tp gcd(_Tp x,_Tp y){ return y?gcd(y,x%y):x; }
	inline int VSC_Local(){
		#ifdef VSC_Compile
		while(getchar() != '\n');
		#endif
		return 0;
	}
	#define FILE(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
	#define PBTXDY
}
using namespace my_std;

const int N = 20010;
int n, K, usd[N];
char sc[N], ans[N];

int main(){
	n = read(), K = read() - 1;
	scanf("%s", sc + 1);
	reg char mn = 'z';
	FOR(i, n + 1, n * 2) sc[i] = sc[(n * 2 + 1) - i], chkmin(mn, sc[i]);
	Rint len = 0, mxl = 0;
	FOR(i, n + 1, n * 2){
		Rint r = i;
		while(sc[r] == mn) ++r;
		chkmax(mxl, r - i);
	}
	FOR(i, n + 1, n * 2){
		Rint r = i;
		while(sc[r] == mn) ++r;
		if(r - i == mxl) usd[r - 1] = 1;
	}
	if(K >= 13 || n <= (1 << K) * mxl){
		FOR(i, 1, n) putchar(mn);
		return VSC_Local();
	}
	len = n - (1 << K) * mxl;
//	printf("%d %d\n", mxl, len);
	FOR(i, 1, n) ans[i] = 'z';
//	FOR(i, 1, n * 2) putchar(usd[i] ^ 48); putchar('\n');

	function<void(int)> check = [&](int x){
		FOR(i, 1, len){
			Rint p = x - mxl + 1 - i;
			if(sc[p] > ans[i]) return;
			if(sc[p] < ans[i]){
				FOR(j, 1, len){
					ans[j] = sc[x - mxl + 1 - j];
				}
				return;
			}
		}
	};

	FOR(i, n + 1, n * 2) if(usd[i]){
		check(i);
	}
	FOR(i, len + 1, n) putchar(mn);
	FOR(i, 1, len) putchar(ans[i]);
	return VSC_Local();
}