#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, k, mi;
char c[N], a[N * 2], b[N], ans[N];
void get(int k, int i, int j) {
  memcpy(a, c, n + 1);
  if (k == 1 && j < n) {
    for (int l = 1, _e = n; l <= _e; ++l) a[n + l] = a[n - l + 1];
    memcpy(a + 1, a + i, n);
    return;
  }
  if (j < n) {
    --k;
    for (int l = 1, _e = n; l <= _e; ++l) a[n + l] = a[n - l + 1];
    memcpy(a + 1, a + n - i + 2, n);
    i = j - i + 1;
  } else
    i = n - i + 1;
  if (k >= 13 || i * (1 << k) >= n) {
    for (int i = 1, _e = n; i <= _e; ++i) a[i] = mi;
    return;
  }
  for (int j = 1, _e = n - i; j <= _e; ++j) b[j] = a[j];
  reverse(b + 1, b + n - i + 1);
  for (int j = 1, _e = i * (1 << k); j <= _e; ++j) a[j] = mi;
  for (int j = i * (1 << k) + 1, _e = n; j <= _e; ++j)
    a[j] = b[j - i * (1 << k)];
}
bool pd(char *a, char *b) {
  for (int i = 1, _e = n; i <= _e; ++i) {
    if (a[i] < b[i]) return 1;
    if (a[i] > b[i]) return 0;
  }
  return 0;
}
int main() {
  cin >> n >> k;
  scanf("\n%s", c + 1);
  memcpy(ans, c, n + 1);
  mi = 255;
  for (int i = 1, _e = n; i <= _e; ++i) mi = min(mi, (int)c[i]);
  for (int i = 1, _e = n; i <= _e; ++i)
    if (c[i] == mi) {
      int j = i;
      for (; j < n && c[j + 1] == mi;) ++j;
      get(k, i, j);
      if (pd(a, ans)) memcpy(ans, a, n + 1);
      i = j;
    }
  for (int i = 1, _e = n; i <= _e; ++i) putchar(ans[i]);
}
