#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long res = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res * f;
}
namespace qiqi {
const int N = 1e4 + 5;
int n, m, k;
char s[N];
void main() {
  n = read();
  m = n << 1;
  k = read();
  int x = 0, y;
  while ((1 << x) < n) ++x;
  k = min(k, x);
  scanf("%s", s + 1);
  for (int i = (1); i <= (n); ++i) s[m - i + 1] = s[i];
  x = 1;
  while (x <= n) {
    int i = y = x, j = x + 1;
    while (j <= m && s[i] <= s[j]) i = s[i] < s[j++] ? x : i + 1;
    while (x < j) x += j - i;
  }
  for (int i = (1); i <= (n); ++i) s[i] = s[i + y - 1];
  s[n + 1] = x = 0;
  for (int i = (1); i <= (n); ++i) {
    ++x;
    if (s[i] != s[i + 1]) break;
  }
  y = min(x << (k - 1), n);
  for (int i = (n); i >= (y + 1); --i) s[i] = s[i - y + x];
  for (int i = (1); i <= (y); ++i) s[i] = s[1];
  puts(s + 1);
}
}  // namespace qiqi
int main() {
  qiqi::main();
  return 0;
}
