#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  int f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
const int N = 5000;
char a[N + 3];
char ans[N + 3][N + 3];
char mnc;
int n, m, num;
bool cmp(int x, int y) {
  for (int i = 1; i <= n; i++) {
    if (ans[x][i] < ans[y][i]) return true;
    if (ans[x][i] > ans[y][i]) return false;
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", a + 1);
  mnc = 'z';
  for (int i = 1; i <= n; i++) mnc = min(mnc, a[i]);
  if (m >= 14) {
    for (int i = 1; i <= n; i++) printf("%c", mnc);
    return 0;
  }
  int len = 0, mxl = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != mnc)
      len = 0;
    else
      len++;
    if (len > mxl) {
      mxl = len;
    }
  }
  len = 0;
  num = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != mnc)
      len = 0;
    else
      len++;
    if (len == mxl) {
      num++;
      if (i == n) {
        int tmp = min(n, len * (1 << m));
        for (int j = 1; j <= tmp; j++) ans[num][j] = mnc;
        for (int j = tmp + 1, k = n - len; j <= n; j++, k--) ans[num][j] = a[k];
      } else {
        int tmp = min(n, len * (1 << m - 1));
        for (int j = 1; j <= tmp; j++) ans[num][j] = mnc;
        for (int j = tmp + 1, k = i + 1; j <= n; j++, k++) {
          ans[num][j] = a[k <= n ? k : 2 * n + 1 - k];
        }
      }
    }
  }
  int fans = 1;
  for (int i = 1; i <= num; i++) {
    if (cmp(i, fans)) {
      fans = i;
    }
  }
  for (int j = 1; j <= n; j++) printf("%c", ans[fans][j]);
  puts("");
  return 0;
}
