#include <bits/stdc++.h>
using namespace std;
namespace fastIO1 {
inline char read() {
  static const int IN_LEN = 1000000;
  static char buf[IN_LEN], *s, *t;
  return (s == t               ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin),
          (s == t ? -1 : *s++) : *s++);
}
template <class T>
inline void read(T &x) {
  static bool iosig;
  static char c;
  for (iosig = false, c = read(); !isdigit(c); c = read()) {
    if (c == '-') iosig = true;
    if (c == -1) return;
  }
  for (x = 0; isdigit(c); c = read()) x = ((x + (x << 2)) << 1) + (c ^ '0');
  if (iosig) x = -x;
}
inline char readc(char &c) {
  for (c = read(); !isalpha(c) && !isdigit(c); c = read())
    if (c == -1) return 0;
}
const int OUT_LEN = 10000000;
char obuf[OUT_LEN], *ooh = obuf;
inline void print(char c) {
  if (ooh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), ooh = obuf;
  *ooh++ = c;
}
template <class T>
inline void print(T x) {
  static int buf[30], cnt;
  if (x == 0)
    print('0');
  else {
    if (x < 0) print('-'), x = -x;
    for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;
    while (cnt) print((char)buf[cnt--]);
  }
}
inline void flush() { fwrite(obuf, 1, ooh - obuf, stdout); }
}  // namespace fastIO1
namespace fastIO2 {
template <class T>
inline void read(T &x) {
  static bool iosig;
  static char c;
  for (iosig = false, c = getchar(); !isdigit(c); c = getchar()) {
    if (c == '-') iosig = true;
    if (c == -1) return;
  }
  for (x = 0; isdigit(c); c = getchar()) x = ((x + (x << 2)) << 1) + (c ^ '0');
  if (iosig) x = -x;
}
}  // namespace fastIO2
using namespace fastIO1;
int n, m, len, mxl, cnt, ot = 1;
char ch[(5010)], mn, ans[(5010)][(5010)];
void GG() {
  for (int i = 1; i <= n; i++) putchar(mn);
  exit(0);
}
void Min(int &x, int y) {
  for (int i = 1; i <= n; i++) {
    if (ans[x][i] < ans[y][i]) return;
    if (ans[x][i] > ans[y][i]) {
      x = y;
      return;
    }
  }
}
int main() {
  read(n), read(m), mn = 'z';
  for (int i = 1; i <= n; i++) readc(ch[i]), mn = min(mn, ch[i]);
  if (m >= 14) GG();
  for (int i = 1; i <= n; i++)
    if (ch[i] != mn)
      len = 0;
    else
      len++, mxl = max(mxl, len);
  len = 0;
  for (int p = 1; p <= n; p++) {
    if (ch[p] != mn)
      len = 0;
    else
      len++;
    if (p == n && len > 0) {
      int L = len << m;
      if (L >= n) GG();
      cnt++;
      for (int i = 1; i <= L; i++) ans[cnt][i] = mn;
      for (int i = L + 1, j = n - len; i <= n; i++, j--) ans[cnt][i] = ch[j];
      puts(ans[cnt] + 1);
    } else if (len == mxl) {
      int L = len << (m - 1);
      if (L >= n) GG();
      cnt++;
      for (int i = 1; i <= L; i++) ans[cnt][i] = mn;
      for (int i = L + 1, j = i + 1; i <= n; i++, j++)
        ans[cnt][i] = ch[j > n ? (2 * n - j + 1) : j];
    }
  }
  for (int i = 2; i <= cnt; i++) Min(ot, i);
  for (int i = 1; i <= n; i++) putchar(ans[ot][i]);
}
