#include <bits/stdc++.h>
using namespace std;
inline void proc_status() {
  ifstream t("/proc/self/status");
  cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>())
       << endl;
}
template <typename T>
inline int chkmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline int chkmax(T &a, const T &b) {
  return b > a ? a = b, 1 : 0;
}
template <typename T>
inline T sqr(const T &val) {
  return val * val;
}
namespace fastIO {
const int MAX_BUFFER_SIZE = 1 << 16;
char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;
inline char getc() {
  return cur == ed && (ed = (cur = buffer) +
                            fread(buffer, 1, MAX_BUFFER_SIZE, stdin),
                       cur == ed)
             ? EOF
             : *cur++;
}
}  // namespace fastIO
using fastIO::getc;
template <typename T>
inline T read() {
  register T sum(0), fg(1);
  register char ch(getc());
  for (; !isdigit(ch); ch = getc())
    if (ch == '-') fg = -1;
  for (; isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
  return sum * fg;
}
inline char *read_str(char *s) {
  register char ch(getc());
  while (!isgraph(ch)) ch = getc();
  for (; isgraph(ch); ch = getc()) *s++ = ch;
  *s = '\0';
  return s;
}
const int MAXN = (int)5e3;
int n, K;
char s[MAXN * 2 + 5];
inline void input() {
  n = read<int>(), K = read<int>();
  read_str(s + 1);
}
inline void solve() {
  char mn = *min_element(s + 1, s + n + 1);
  for (int i = 1; i <= n; ++i) s[n + i] = s[i];
  reverse(s + n + 1, s + 2 * n + 1);
  for (int i = 1, j; i <= n; i = j) {
    if (s[i] != mn) {
      j = ++i;
      continue;
    }
    for (j = i; j <= n && s[j] == mn; ++j)
      ;
    if ((j - i) * (1 << (K - (j <= n))) >= n) {
      for (int k = 0; k < n; ++k) putchar(mn);
      return;
    }
  }
  string ans;
  for (int i = 1; i <= n; ++i) ans += s[i];
  for (int i = 1; i <= n + 1; ++i) {
    int r = i + n - 1;
    if (s[r] == mn) {
      int cnt = 0;
      while (cnt < n && s[r - cnt] == mn) ++cnt;
      string res = "";
      int len = n;
      for (int k = 0; k < cnt * (1 << (K - 1)); ++k) res += mn, --len;
      for (int k = r - cnt; len > 0; --k, --len) res += s[k];
      chkmin(ans, res);
    }
  }
  printf("%s\n", ans.c_str());
}
int main() {
  input();
  solve();
  return 0;
}
