#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const int N=5000;

int n,m;
char s[N+9];

void into(){
  scanf("%d%d%s",&n,&m,s+1);
  m=min(m,15);
}

char ans[N+9],tmp[N+9];

bool Check_cmp(){
  if (!ans[1]) return 1;
  for (int i=1;i<=n;++i)
	if (tmp[i]^ans[i]) return tmp[i]<ans[i];
  return 0;
}

void Get_ans(){
  char mn='z';
  for (int i=1;i<=n;++i) mn=min(mn,s[i]);
  int mx=0;
  for (int i=1,c=0;i<=n;++i){
	s[i]==mn?++c:c=0;
	mx=max(mx,c<<(i==n));
  }
  if (mx*(1<<m-1)>=n){
	for (int i=1;i<=n;++i) ans[i]=mn;
	return;
  }
  for (int i=1,c=0;i<=n;++i){
	s[i]==mn?++c:c=0;
	if (c<<(i==n)<mx) continue;
	int ct=0;
	for (int j=1;j<=mx*(1<<m-1);++j) tmp[++ct]=mn;
	for (int j=i+1;j<=n&&ct<n;++j) tmp[++ct]=s[j];
	for (int j=i==n?n-c:n;j>=1&&ct<n;--j) tmp[++ct]=s[j];
    if (Check_cmp())
	  for (int j=1;j<=n;++j) ans[j]=tmp[j];
  }
}

void work(){
  Get_ans();
}

void outo(){
  for (int i=1;i<=n;++i)
	putchar(ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}