#include <bits/stdc++.h>
using namespace std;
namespace io {
const int l = 1 << 20;
char buf[l], *s, *t, c;
inline void gc() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, l, stdin);
    c = s == t ? EOF : *s++;
  } else
    c = *s++;
}
template <class IT>
inline void gi(IT &x) {
  x = 0;
  gc();
  while (c < '0' || c > '9') gc();
  while ('0' <= c && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    gc();
  }
}
char buf0[20];
int a;
template <class IT>
inline void pi(IT x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  do buf0[++a] = x % 10 + 48;
  while (x /= 10);
  while (a) putchar(buf0[a--]);
  putchar('\n');
}
};  // namespace io
using io::gi;
using io::pi;
template <class IT>
inline void cmax(IT &a, IT b) {
  if (a < b) a = b;
}
template <class IT>
inline void cmin(IT &a, IT b) {
  if (b < a) a = b;
}
const int N = 5005;
char c[N << 1], a[N], b[N];
int main() {
  int n, i, j, k, m, t = 0, x = 0, len, nle, sta, f;
  char ming = 'z';
  scanf("%d%d%s", &n, &k, c + 1);
  m = n << 1 | 1;
  for (i = (1); i <= (n); ++i) b[i] = c[i];
  for (i = (1); i <= (n); ++i) cmin(ming, c[m - i] = c[i]);
  for (i = (1); i < (m); ++i) {
    if (c[i] == ming)
      cmax(x, ++t);
    else
      t = 0;
  }
  if (k > 13 || (len = (x << (k - 1))) >= n) {
    for (i = (1); i <= (n); ++i) putchar(ming);
    return 0;
  }
  nle = n - len;
  sta = len - (x + n);
  t = 0;
  for (j = (1); j < (m); ++j) {
    ++sta;
    if (c[j] == ming) {
      if (x == (++t) && j > n) {
        f = 0;
        for (i = (nle); i >= (1); --i) a[i] = c[i + sta];
        for (i = (nle); i >= (1); --i)
          if (a[i] != b[i]) {
            f = (a[i] < b[i]);
            break;
          }
        if (f)
          for (i = (nle); i >= (1); --i) b[i] = a[i];
      }
    } else
      t = 0;
  }
  for (i = (len); i >= (1); --i) putchar(ming);
  for (i = (nle); i >= (1); --i) putchar(b[i]);
  return 0;
}
