#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=100100;
int n,K,L;
char x,s[N],t[N],a[N],b[N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d%s",&n,&K,s+1);
	if(n==1) return puts(s+1),0;
	a[1]=x='z'+1;
	FOR(i,1,n) x=min(x,s[i]),s[i+n]=s[n-i+1];
	if(K>=14){FOR(i,1,n) putchar(x);return 0;}
	for(int l=1,r;l<=n;l=r+1){
		for(r=l;r<n && s[r]==s[r+1];r++);
		if(s[l]>x) continue;
		L=(1<<K-(r<n))*(r-l+1);
		if(L>=n){
			FOR(i,1,n) putchar(x);
			return 0;
		}
		FOR(i,1,L) b[i]=x;
		FOR(i,1,n-L) b[i+L]=r<n?s[2*n-r+1-i]:s[l-i];
		//cout<<l<<' '<<r<<' '<<L<<'\n';puts(s+1);puts(b+1);
		FOR(i,1,n)if(b[i]!=a[i]){
			if(b[i]<a[i]) FOR(j,1,n) a[j]=b[j];
			break;
		} 
	}
	puts(a+1);
} 