#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int stack[20];
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int top = 0;
  while (x) stack[++top] = x % 10, x /= 10;
  while (top) putchar(stack[top--] + '0');
}
template <typename T>
inline void pr1(T x) {
  write(x);
  putchar(' ');
}
template <typename T>
inline void pr2(T x) {
  write(x);
  putchar('\n');
}
const int MAXN = 10005;
char ch[MAXN], ch1[MAXN], ln;
int n, K, vi[MAXN];
int main() {
  n = read();
  K = read();
  scanf("%s", ch + 1);
  int mn = 999999999;
  for (int i = 1; i <= n; i++) mn = min(mn, ch[i] - 'a' + 1);
  for (int i = n + 1; i <= 2 * n; i++) ch[i] = ch[n - (i - n) + 1];
  int mxp = 0;
  for (int i = 2 * n, j; i >= 1; i = j - 1) {
    j = i;
    if (ch[i] - 'a' + 1 == mn) {
      while (ch[j - 1] == ch[i]) j--;
      mxp = max(mxp, i - j + 1);
      vi[i] = i - j + 1;
    }
  }
  int u = mxp, t = 0;
  while (u < n && t < K - 1) u <<= 1, ++t;
  if (u >= n) {
    for (int i = 1; i <= n; i++) putchar(mn + 'a' - 1);
    puts("");
    return 0;
  }
  for (int i = 1; i <= u; i++) putchar(mn + 'a' - 1);
  ln = 0;
  u = n - u;
  for (int i = 2 * n; i >= n; i--)
    if (vi[i] == mxp) {
      if (!ln) {
        for (int j = i - mxp; j >= i - mxp - u + 1; j--) ch1[++ln] = ch[j];
        continue;
      }
      bool tf = true;
      for (int j = i - mxp, o = 1; j >= i - mxp - u + 1; j--, o++) {
        if (ch[j] - 'a' < ch1[o] - 'a') break;
        if (ch[j] - 'a' > ch1[o] - 'a') {
          tf = false;
          break;
        }
      }
      if (tf) {
        ln = 0;
        for (int j = i - mxp; j >= i - mxp - u + 1; j--) ch1[++ln] = ch[j];
      }
    }
  for (int i = 1; i <= ln; i++) putchar(ch1[i]);
  puts("");
  return 0;
}
