#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, K;
int mxR[N];
char s[N << 1], t[N], ans[N];
void check(char* s, int k, char min_c) {
  int L = 0, p = n;
  while (s[n - L] == min_c) L++, p--;
  L <<= k;
  if (L >= n) {
    for (int i = 1; i <= n; i++) putchar(min_c);
    putchar('\n');
    return;
  }
  for (int i = 1; i <= L; i++) {
    t[i] = min_c;
  }
  for (int i = L + 1; i <= n; i++) t[i] = s[p--];
  for (int i = 1; i <= n; i++)
    if (t[i] ^ ans[i]) {
      if (t[i] > ans[i]) {
        return;
      }
      break;
    }
  for (int i = 1; i <= n; i++) ans[i] = t[i];
}
int main() {
  scanf("%d%d", &n, &K);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) s[2 * n - i + 1] = s[i];
  char x = 'z', y = 'a';
  for (int i = 1; i <= n; i++) {
    x = min(x, s[i]);
    y = max(y, s[i]);
  }
  if (K >= 20 || x == y) {
    for (int i = 1; i <= n; i++) putchar(x);
    putchar('\n');
    return 0;
  }
  ans[1] = 'z' + 1;
  if (s[n] == x) check(s, K, x);
  int mxL = 0;
  for (int i = 1, j; i <= n; i = j) {
    if (s[i] != x) {
      j++;
      continue;
    }
    while (s[j] == s[i]) j++;
    mxR[i] = j - i;
    mxL = max(mxL, mxR[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (mxR[i] == mxL) {
      check(s + (n - i + 1), K - 1, x);
    }
  }
  puts(ans + 1);
  return 0;
}
