#include<bits/stdc++.h>
#define N 5005
using namespace std;
int n,k;
char a[N],ans[N],now[N];

bool leq(char *a,char *b) 
{
	for(int i=0;i<n;++i)
	{
		if(a[i] < b[i]) return true;
		if(a[i] > b[i])	return false;
	}
	return false;
}
int main()
{
	scanf("%d%d%s",&n,&k,a);
	k = min(k,30);
	for(int i=0;i<n;++i) ans[i] = 'z';
	int mn = 'z',len = 0,mx = 0;
	for(int i=0;i<n;++i) if(mn > a[i]) mn = a[i];
	for(int i=0;i<n;++i)
	{
		if(mn != a[i]) len = 0; else ++len;
		mx = max(mx,len);
	}
	len = 0;
	for(int i=0;i<n;++i)
	{
		if(mn != a[i]) len = 0; else ++len;
		if(i == n - 1 && a[i] == mn)
		{
			int tmp = min(n,(1<<k) * len);
			for(int j=0;j<tmp;++j) now[j] = mn;
			for(int j=tmp,k=n - len - 1;j<n;++j,--k) now[j] = a[k];
			if(leq(now,ans)) for(int j=0;j<n;++j) ans[j] = now[j];
		}
		if(len == mx)
		{
			int tmp = min(n,(1<<(k-1)) * len);
			for(int j=0;j<tmp;++j) now[j] = mn;
			for(int j=tmp,k=i+1;j<n;++j,++k) now[j] = a[k < n ? k : 2 * n - k - 1];
			if(leq(now,ans)) for(int j=0;j<n;++j) ans[j] = now[j];
		}
	}
	for(int i=0;i<n;++i) printf("%c",ans[i]);
	return 0;
}