#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 6005;
const int mod = 1e9 + 7;
int n, k;
string s;
void dfs(string x, int k) {
  if (k == 0)
    s = min(s, x);
  else {
    for (int i = 0; i <= n; i++) {
      string p = x.substr(n - i, i);
      string q = x.substr(i, n - i);
      reverse(q.begin(), q.end());
      dfs(p + q, k - 1);
    }
  }
}
int main() {
  cin >> n >> k >> s;
  dfs(s, k);
  cout << s << endl;
}
