#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, k, mx;
char s[5005], p;
string ans;
int main() {
  n = read(), k = min(read(), 15);
  scanf("%s", s + 1);
  p = *min_element(s + 1, s + n + 1);
  for (int i = 1, j = 0; i <= n; ++i) {
    if (s[i] == p)
      ++j;
    else
      j = 0;
    mx = max(mx, j);
  }
  if (mx * (1 << k - 1) >= n) {
    ans = string(n, p);
    goto End;
  }
  for (int i = 1, j = 0; i <= n; ++i) {
    if (s[i] == p)
      ++j;
    else
      j = 0;
    if (j < mx) continue;
    string tmp = "";
    for (int t = 1; t <= mx * (1 << k - 1); ++t) {
      tmp += p;
    }
    int res = n - mx * (1 << k - 1);
    for (int t = i + 1; t <= n && res; ++t, --res) {
      tmp += s[t];
    }
    for (int t = n; t >= 1 && res; --t, --res) {
      tmp += s[t];
    }
    if (ans.empty() || ans > tmp) {
      ans = tmp;
    }
  }
End:
  cout << ans << endl;
  return 0;
}
