#include <bits/stdc++.h>
int i, j, k, l, n;
char c[10001], x[10001], y[10001];
int main() {
  scanf("%d%d%s", &n, &k, c + 1), k--;
  for (i = 1, j = n << 1; i <= n; c[j--] = c[i++]) y[i - 1] = 'z';
  for (i = j = 1; i <= n; i = j) {
    while (j <= n && c[i] == c[j]) j++;
    if (k > 12 || j - i << k >= n)
      memset(x, c[i], n);
    else
      memset(x, c[i], j - i << k),
          memcpy(x + (j - i << k), c + j, n - (j - i << k));
    if (strcmp(x, y) < 0) memcpy(y, x, n);
  }
  return 0 * printf("%s\n", y);
}
