#include <bits/stdc++.h>
using namespace std;
int n, k, last, mx, len;
char a, s[10010], ans[5050] = {0, 'z'}, now[5050];
void work(int l) {
  for (int i = 1; i <= len; ++i) now[n - len + i] = s[l - mx + 1 - i];
  for (int i = 1; i <= n - len; ++i) now[i] = a;
  for (int i = 1; i <= n; ++i)
    if (now[i] != ans[i]) {
      if (now[i] < ans[i]) swap(now, ans);
      return;
    }
}
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s + 1);
  a = 'z';
  for (int i = 1; i <= n; ++i) s[2 * n + 1 - i] = s[i], a = min(a, s[i]);
  if (k >= 14) {
    for (int i = 1; i <= n; ++i) putchar(a);
    return 0;
  }
  last = 1, mx = 0, len;
  for (int i = 1; i <= 2 * n; ++i)
    if (s[i] != a) mx = max(mx, i - last), last = i + 1;
  len = mx;
  for (int i = 1; i < k; ++i) len <<= 1;
  if (len >= n) {
    for (int i = 1; i <= n; ++i) putchar(a);
    return 0;
  }
  len = n - len;
  last = 1;
  for (int i = 1; i <= 2 * n; ++i)
    if (s[i] != a) {
      if (i - last == mx && i - 1 >= n) work(i - 1);
      last = i + 1;
    }
  for (int i = 1; i <= n; ++i) putchar(ans[i]);
  return 0;
}
