#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, K, L;
char x, s[N], t[N], a[N], b[N];
int main() {
  scanf("%d%d%s", &n, &K, s + 1);
  if (n == 1) return puts(s + 1), 0;
  a[1] = x = 'z' + 1;
  for (int i = 1; i <= n; i++) x = min(x, s[i]), s[i + n] = s[n - i + 1];
  if (K >= 14) {
    for (int i = 1; i <= n; i++) putchar(x);
    return 0;
  }
  for (int l = 1, r; l <= n; l = r + 1) {
    for (r = l; r <= n && s[r] == s[r + 1]; r++)
      ;
    if (s[l] > x) continue;
    L = (1 << K - 1) * (r - l + 1);
    if (r == n) L <<= 1;
    if (L >= n) {
      for (int i = 1; i <= n; i++) putchar(x);
      return 0;
    }
    for (int i = 1; i <= L; i++) b[i] = x;
    for (int i = 1; i <= n - L; i++)
      b[i + L] = r < n ? s[2 * n - r + 1 - i] : s[l - i];
    for (int i = 1; i <= n; i++)
      if (b[i] != a[i]) {
        if (b[i] < a[i])
          for (int j = 1; j <= n; j++) a[j] = b[j];
        break;
      }
  }
  puts(a + 1);
}
