#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  string s;
  cin >> n >> k >> s;
  char c = 'z';
  for (long long i = (0); i < ((n)); ++i) c = min(c, s[i]);
  long long cnt = 1, num = 1;
  while (num < n) cnt++, num *= 2;
  if (k >= cnt) {
    for (long long i = (0); i < ((n)); ++i) cout << c;
    cout << endl;
    return 0;
  }
  for (long long x = (0); x < ((k - 1)); ++x) {
    string t = s;
    reverse(t.begin(), t.end());
    string u = s + t;
    reverse(u.begin(), u.end());
    string res = t;
    for (long long i = (0); i < ((n)); ++i) res = min(res, u.substr(i + 1, n));
    reverse(res.begin(), res.end());
    s = res;
  }
  string t = s;
  reverse(t.begin(), t.end());
  string u = s + t;
  string res = s;
  for (long long i = (0); i < ((n)); ++i) res = min(res, u.substr(i + 1, n));
  s = res;
  cout << s << endl;
  return 0;
}
