#include <bits/stdc++.h>
using namespace std;
int n;
string ans;
void solve(string s, int K) {
  char c = s.back();
  for (int i = 0; i < K; i++) {
    int l = n - 1;
    while (l > 0 && s[l - 1] == c) l--;
    string ns;
    for (int j = l; j < n; j++) ns.push_back(s[j]);
    for (int j = n - 1; j >= n - l; j--) ns.push_back(s[j]);
    s = ns;
  }
  ans = min(ans, s);
}
string s;
int K;
int main() {
  ans.push_back(char('z' + 1));
  cin >> n >> K;
  cin >> s;
  K = min(K, 14);
  string t = s;
  reverse(t.begin(), t.end());
  string ss = s + t;
  for (int i = 0; i <= n; i++) {
    solve(ss.substr(i, n), K - 1);
  }
  cout << ans << endl;
  return 0;
}
