#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int INF = 0x3f3f3f3f;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
char s[MAXN], mn, ans[MAXN >> 1][MAXN];
int n, k, mxl, t;
void init() {
  read(n);
  read(k);
  scanf("%s", s + 1);
  mn = 'z';
  for (int i = 1; i <= n; ++i) {
    mn = min(mn, s[i]);
  }
  if (k >= 14) {
    for (int i = 1; i <= n; ++i) {
      putchar(mn);
    }
    exit(0);
  }
  for (int i = 1, j = 0; i <= n; ++i) {
    if (s[i] != mn) {
      j = 0;
    } else {
      mxl = max(mxl, ++j);
    }
  }
}
inline bool check(int x, int y) {
  for (int i = 1; i <= n; ++i) {
    if (ans[x][i] < ans[y][i]) return 1;
    if (ans[x][i] > ans[y][i]) return 0;
  }
  return 0;
}
void solve() {
  for (int i = 1, j = 0; i <= n; ++i) {
    if (s[i] != mn) {
      j = 0;
    } else if ((++j) == mxl || i == n) {
      ++t;
      int tmp = min(n, j << (k - (i != n))), x, y;
      for (x = 1; x <= tmp; ++x) {
        ans[t][x] = mn;
      }
      for (y = i + 1; x <= n && y <= n; ++x, ++y) {
        ans[t][x] = s[y];
      }
      for (y = n; x <= n && y; ++x, --y) {
        ans[t][x] = s[y];
      }
    }
  }
  int p = 1;
  for (int i = 2; i <= t; ++i) {
    if (check(i, p)) p = i;
  }
  for (int i = 1; i <= n; ++i) {
    putchar(ans[p][i]);
  }
}
int main() {
  init();
  solve();
  return 0;
}
