#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5010;
char a[MAXN], ans[MAXN][MAXN], Min;
int n, m, num, len, maxlen, Ans = 1;
inline bool cmp(register int x, register int y) {
  for (register int i = 1; i <= n; i++) {
    if (ans[x][i] < ans[y][i]) return true;
    if (ans[x][i] > ans[y][i]) return false;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> (a + 1);
  Min = 'z';
  for (register int i = 1; i <= n; i++) Min = min(Min, a[i]);
  if (m >= 14) {
    for (register int i = 1; i <= n; i++) cout << Min;
    return 0;
  }
  for (register int i = 1; i <= n; i++)
    len = ((a[i] == Min) ? len + 1 : 0), maxlen = max(maxlen, len);
  for (register int i = 1; i <= n; i++) {
    len = ((a[i] == Min) ? len + 1 : 0);
    if (i == n) {
      num++;
      register int tmp = min(n, (len << m));
      for (register int j = 1; j <= tmp; j++) ans[num][j] = Min;
      for (register int j = tmp + 1, k = n - len; j <= n; j++, k--)
        ans[num][j] = a[k];
    }
    if (len == maxlen) {
      num++;
      register int tmp = min(n, (len << (m - 1)));
      for (register int j = 1; j <= tmp; j++) ans[num][j] = Min;
      for (register int j = tmp + 1, k = i + 1; j <= n; j++, k++)
        ans[num][j] = a[(k <= n) ? k : ((n << 1 | 1) - k)];
    }
  }
  for (register int i = 1; i <= num; i++)
    if (cmp(i, Ans)) Ans = i;
  for (register int i = 1; i <= n; i++) cout << ans[Ans][i];
  return 0;
}
