#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = v * 10 + c - '0';
    c = getchar();
  }
  return v * f;
}
const int Maxn = 5005;
int n, k;
char s[Maxn];
char Ans[Maxn], tmp[Maxn];
void Ckmin() {
  int flag = 0;
  for (int i = 0; i < n; i++) {
    if (Ans[i] < tmp[i]) return;
    if (Ans[i] > tmp[i]) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    for (int i = 0; i < n; i++) Ans[i] = tmp[i];
  }
}
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s);
  reverse(s, s + n);
  if (k >= 20 || (1 << (k - 1)) >= n) {
    char Mn = 'z';
    for (int i = 0; i < n; i++) {
      Mn = min(Mn, s[i]);
    }
    for (int i = 0; i < n; i++) {
      putchar(Mn);
    }
    printf("\n");
    return 0;
  }
  for (int i = 0; i < n; i++) Ans[i] = 'z';
  char Mn = 'z';
  for (int i = 0; i < n; i++) {
    Mn = min(Mn, s[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == Mn)
      cnt++;
    else
      cnt = 0;
    if (s[i] == Mn) {
      if ((cnt << (k - 1)) >= n) {
        for (int j = 0; j < n; j++) {
          putchar(Mn);
        }
        printf("\n");
        return 0;
      }
      int dd = cnt << (k - 1);
      for (int j = 0; j < dd; j++) tmp[j] = Mn;
      for (int j = dd, k = i - cnt; j < n; j++, k--) {
        char t = s[(k >= 0) ? k : (-k - 1)];
        tmp[j] = t;
      }
      Ckmin();
      cnt = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    putchar(Ans[i]);
  }
  printf("\n");
  return 0;
}
