#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int N = 5005 * 2;
int n, k;
char s[N], mi = 'z';
int cl[N];
int cmp(char *a, char *b, int len) {
  for (int i = (0); i <= (len - 1); i++)
    if (a[i] != b[i]) return a[i] < b[i];
  return 0;
}
int main() {
  n = read(), k = read() - 1;
  cin >> (s + 1);
  for (int i = (1); i <= (n); i++) s[i + n] = s[i];
  reverse(s + n + 1, s + n * 2 + 1);
  for (int i = (1); i <= (n); i++) mi = min(mi, s[i]);
  for (int i = (1); i <= (n * 2); i++)
    cl[i] = s[i] != s[i - 1] ? 1 : cl[i - 1] + 1;
  int mx = 1;
  for (int i = (1); i <= (n * 2); i++)
    if (s[i] == mi) mx = max(mx, cl[i]);
  k = min(k, 15);
  if ((mx << k) >= n) {
    for (int i = (1); i <= (n); i++) putchar(mi);
    puts("");
    return 0;
  }
  int rlen = n - (mx << k);
  int res = 0;
  for (int i = (1); i <= (n * 2 - rlen); i++)
    if (s[i] == mi && cl[i] == mx) {
      if (!res || !cmp(s + res, s + i + 1, rlen)) res = i + 1;
    }
  for (int i = (1); i <= ((mx << k)); i++) putchar(mi);
  for (int i = (0); i <= (rlen - 1); i++) putchar(s[res + i]);
  puts("");
  return 0;
}
