#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 11000;
int n, k, len, mx, vis, l[N << 1];
char s[N << 1], res[N << 1], c = 'z';
void copy(int p) {
  for (int i = 1; i <= n; i++) res[i] = s[p + i - 1];
}
void check(int p) {
  if (!vis) copy(p), vis = 1;
  for (int i = 1; i <= n; i++) {
    if (res[i] < s[p + i - 1]) return;
    if (res[i] > s[p + i - 1]) return copy(p);
  }
}
int main() {
  n = read();
  k = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) c = min(c, s[(n << 1) + 1 - i] = s[i]);
  if (k >= 15) {
    for (int i = 1; i <= n; i++) putchar(c);
    return 0;
  }
  if (k == 1) {
    for (int i = 1; i <= n + 1; i++) check(i);
    for (int i = 1; i <= n; i++) putchar(res[i]);
    return 0;
  }
  for (int i = 1; i <= (n << 1); i++)
    if (s[i] == c) mx = max(l[i] = l[i - 1] + 1, mx);
  if ((len = mx << k - 1) >= n) {
    for (int i = 1; i <= n; i++) putchar(c);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (l[i] == mx) check(i - l[i] + 1);
  for (int i = 1; i <= len; i++) putchar(c);
  for (int i = len + 1; i <= n; i++) putchar(res[i - len + mx]);
  return 0;
}
