#include <bits/stdc++.h>
using namespace std;
int n, k;
const int maxn = 2 * (5e3 + 10);
char s[maxn];
char ans[maxn];
char tmp[maxn];
void check() {
  for (int i = 1; i <= n; ++i) {
    if (ans[i] < tmp[i]) return;
    if (tmp[i] < ans[i]) {
      for (int j = 1; j <= n; ++j) ans[j] = tmp[j];
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%s", s + 1);
  char c = 'z';
  for (int i = 1; s[i]; ++i) {
    c = min(c, s[i]);
  }
  for (int i = 1; s[i]; ++i) {
    s[2 * n - i + 1] = ans[i] = s[i];
  }
  ans[n + 1] = 0;
  if (s[n] == c) {
    int len = 0, y = k;
    for (int i = n; s[i] == c; --i) len++;
    int pos = n - len;
    while (len < n && y--) len <<= 1;
    if (len < n) {
      for (int i = 1; i <= len; ++i) tmp[i] = c;
      for (int i = len + 1; i <= n; ++i) tmp[i] = s[pos--];
    } else {
      for (int i = 1; i <= n; ++i) tmp[i] = c;
    }
    check();
  }
  for (int i = n + 1; i <= 2 * n; ++i) {
    int len = 0;
    if (i + 1 <= 2 * n)
      while (s[i] == s[i + 1]) i++;
    int pos = i + 1;
    if (s[i] == c) {
      for (int j = i; s[j] == c; --j) len++;
      int y = k - 1;
      while (len < n && y--) len <<= 1;
      if (len < n) {
        for (int i = 1; i <= len; ++i) tmp[i] = c;
        for (int i = len + 1; i <= n; ++i) tmp[i] = s[pos++];
      } else {
        for (int i = 1; i <= n; ++i) tmp[i] = c;
      }
      check();
    }
  }
  printf("%s\n", ans + 1);
}
