#include <bits/stdc++.h>
using namespace std;
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 998244353;
  if (b & 1) ns = ns * a % 998244353;
  return ns;
}
inline int add(int a, int b) {
  a += b;
  return (a < 998244353) ? a : (a - 998244353);
}
inline int sub(int a, int b) {
  a -= b;
  return (a < 0) ? a + 998244353 : a;
}
inline int mul(int a, int b) { return (long long)a * b % 998244353; }
int n, k;
char inp[10005];
char ans[10005];
char nans[10005];
int main() {
  cin >> n >> k;
  scanf("%s", inp);
  for (int i = 0; i < n; i++) ans[i] = 'z';
  for (int i = 0; i < n; i++) inp[2 * n - 1 - i] = inp[i];
  char mn = 'z';
  for (int i = 0; i < 2 * n; i++)
    if (inp[i] < mn) mn = inp[i];
  if (k >= 14) {
    for (int i = 0; i < n; i++) cout << mn;
    return 0;
  }
  for (int i = n - 1; i < 2 * n; i++) {
    if (inp[i] != mn) continue;
    if (inp[i + 1] == mn) continue;
    int nl = 0;
    for (int j = i; j >= 0; j--)
      if (inp[j] == mn)
        nl++;
      else
        break;
    int ns = (1 << (k - 1)) * nl;
    int cnt = 0;
    int fl = 0;
    for (int k = 0; k < n; k++) {
      if (k < ns)
        nans[k] = mn;
      else
        nans[k] = inp[i - nl - cnt], cnt++;
      if (ans[k] != nans[k]) {
        if (ans[k] < nans[k])
          break;
        else {
          fl = 1;
        }
      }
    }
    if (fl) {
      for (int k = 0; k < n; k++) ans[k] = nans[k];
    }
  }
  cout << ans;
  return 0;
}
