#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e4+5;

int n,k;
char st[N],an[N],tmp[N];

void chk() {
	fo(i,1,n) {
		if (an[i]<tmp[i]) return;
		if (tmp[i]<an[i]) {
			fo(j,1,n) an[j]=tmp[j];
			return;
		}
	}
}

int main() {
	scanf("%d%d",&n,&k);
	scanf("%s",st+1);
	char c='z';
	fo(i,1,n) c=min(c,st[i]);
	fo(i,1,n) st[2*n-i+1]=an[i]=st[i];
	if (st[n]==c) {
		int pos=n,len=0,y=k;
		for(;pos>=1&&st[pos]==c;pos--) len++;
		for(;len<n&&y;y--) len<<=1;
		if (len<n) {
			fo(i,1,len) tmp[i]=c;
			fo(i,len+1,n) tmp[i]=st[pos--];
		} else fo(i,1,n) tmp[i]=c;
		chk();
	}
	for(int l=n+1,r=n;l<=n*2;l=r+1) {
		while (r<n*2&&st[r+1]==st[l]) r++;
		if (st[l]==c) {
			int len=0,pos=r,y=k-1;
			for(;pos>=r-n+1&&st[pos]==c;pos--) len++; 
			for(;len<n&&y;y--) len<<=1;
			if (len<n) {
				fo(i,1,len) tmp[i]=c;
				fo(i,len+1,n) tmp[i]=st[pos--];
			} else fo(i,1,n) tmp[i]=c;
			chk();
		}
	}
	printf("%s\n",an+1);
	return 0;
}