#include <bits/stdc++.h>
using namespace std;
int n, k, L, f[10005], ans;
char c[10005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf(" %c", c + i);
  char C = 'z';
  for (int i = 1; i <= n; ++i) C = min(C, c[i]);
  if (k > 20) {
    for (int i = 1; i <= n; ++i) printf("%c", C);
    printf("\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) c[n * 2 + 1 - i] = c[i];
  for (int i = 1; i <= n * 2; ++i) {
    if (c[i] != C) continue;
    if (i > 1 && c[i - 1] == C)
      f[i] = f[i - 1] + 1;
    else
      f[i] = 1;
    L = max(L, f[i]);
  }
  int _ = L;
  for (int i = 1; i < k; ++i) {
    _ *= 2;
    if (_ >= n) break;
  }
  if (_ >= n) {
    for (int i = 1; i <= n; ++i) printf("%c", C);
    printf("\n");
    return 0;
  }
  _ = n - _;
  for (int i = n + 1; i <= n * 2; ++i) {
    if (f[i] < L) continue;
    if (!ans) {
      ans = i;
      continue;
    }
    int t = 0;
    for (int j = 0; j < _; ++j) {
      if (c[ans - j - L] == c[i - j - L]) continue;
      if (c[ans - j - L] < c[i - j - L])
        t = 1;
      else
        t = 2;
    }
    if (t == 1) ans = i;
  }
  for (int i = 1; i <= n - _; ++i) printf("%c", C);
  for (int i = 0; i < _; ++i) printf("%c", c[ans - i - L]);
  printf("\n");
  return 0;
}
