#include <bits/stdc++.h>
using namespace std;
int n;
char s[11111], res[5555], tmp[5555], tmp2[5555];
void upd() {
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (tmp2[i] < res[i]) {
      flag = 1;
      break;
    } else if (tmp2[i] > res[i])
      break;
  }
  if (flag) memcpy(res, tmp2, (n + 3) * sizeof(char));
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  scanf("%s", s + 1);
  char minchar = 'z';
  for (int i = 1; i <= n; i++) minchar = min(minchar, s[i]);
  int bef = 0, maxnum = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == minchar)
      bef++;
    else
      bef = 0;
    maxnum = max(maxnum, bef);
  }
  int now = bef;
  for (int i = 1; i <= k; i++) {
    now = min(n, bef * 2);
    if (now == n) break;
  }
  int now2 = maxnum;
  for (int i = 1; i < k; i++) {
    now2 = min(n, now2 * 2);
    if (now2 == n) break;
  }
  res[1] = 'z' + 1;
  if (now == n || now2 == n) {
    for (int i = 1; i <= n; i++) putchar(minchar);
    return 0;
  }
  bef = 0;
  for (int i = 1; i <= n; i++) s[n + (n - i + 1)] = s[i];
  for (int i = 1; i <= now2; i++) tmp2[i] = minchar;
  for (int i = 1; i <= n; i++) {
    if (s[i] == minchar)
      bef++;
    else
      bef = 0;
    if (bef == maxnum) {
      int k = n + (n - i + 1) + bef - 1;
      for (int i = 1; i <= n; i++) tmp[i] = s[k - (n - i)];
      for (int i = now2 + 1; i <= n; i++)
        tmp2[i] = tmp[n - maxnum - (i - now2 - 1)];
      upd();
    }
  }
  if (bef) {
    for (int i = 1; i <= now; i++) tmp2[i] = minchar;
    for (int i = now + 1; i <= n; i++) tmp2[i] = s[n - bef - (i - now - 1)];
    upd();
  }
  printf("%s\n", res + 1);
}
