#include <bits/stdc++.h>
using namespace std;
char ans[5010], tmp[5010];
int f[10010];
char S[10010];
int n, k;
char mnc;
void upd(int pos, int len) {
  for (int i = 1; i <= min(len, n); i++) tmp[i] = mnc;
  for (int i = min(len, n); i < n; i++) tmp[i + 1] = S[pos - (i - len)];
  for (int i = 1; i <= n; i++)
    if (ans[i] > tmp[i]) {
      for (int j = 1; j <= n; j++) ans[j] = tmp[j];
      return;
    } else if (ans[i] < tmp[i])
      return;
}
int main() {
  scanf("%d %d", &n, &k);
  k = min(k, 14);
  scanf("%s", S + 1);
  mnc = 'z';
  for (int i = n; i >= 1; i--) {
    ans[i] = S[i];
    S[2 * n + 1 - i] = S[i];
    mnc = min(mnc, S[i]);
  }
  int mx = 0;
  for (int i = n; i >= 1; i--) {
    if (S[i] == mnc)
      f[i] = f[i + 1] + 1;
    else
      f[i] = 0;
    mx = max(mx, f[i]);
  }
  int len = mx;
  for (int i = 1; i < k; i++) {
    len <<= 1;
    if (len >= n) {
      len = n;
      break;
    }
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (S[i] == mnc)
      f[i] = f[i - 1] + 1;
    else
      f[i] = 0;
    if (f[i] == mx && i >= n) upd(i - mx - n + len + 1, len);
  }
  printf("%s\n", ans + 1);
  return 0;
}
