#include <bits/stdc++.h>
using namespace std;
long long n, k;
string s;
long long mypow(long long a, long long b) {
  if (!b) return 1;
  if (b % 2) return mypow(a, b - 1) * a;
  long long memo = mypow(a, b / 2);
  return memo * memo;
}
signed main() {
  cin >> n >> k >> s;
  k = min(k, (long long)13);
  char mi = 'z';
  for (long long i = 0; i < n; i++) mi = min(mi, s[i]);
  long long ma = 0, cnt = 0;
  if (s[0] == mi) cnt = 1;
  for (long long i = 1; i <= n - 1; i++) {
    if (s[i - 1] == s[i] && s[i] == mi)
      cnt++;
    else {
      ma = max(ma, cnt);
      if (s[i] == mi)
        cnt = 1;
      else
        cnt = 0;
    }
  }
  ma = max(ma, cnt);
  if (n <= mypow(2, k) * ma) {
    for (long long i = 0; i < n; i++) cout << mi;
    cout << endl;
    return 0;
  }
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  string ans(n, 'z');
  for (long long i = 0; i < n; i++) {
    t = s.substr(i, n);
    cnt = 0;
    for (long long i = n - 1; i >= 0; i--) {
      if (t[i] == mi)
        cnt++;
      else
        break;
    }
    string r =
        t.substr((mypow(2, k - 1) - 1) * cnt, n - mypow(2, k - 1) * cnt) +
        string(mypow(2, k - 1) * cnt, mi);
    reverse(r.begin(), r.end());
    ans = min(ans, r);
  }
  cout << ans << endl;
  return 0;
}
