#include <bits/stdc++.h>
using namespace std;
string reverseStr(string s) {
  int n = s.size();
  for (int i = 0; i < n / 2; i++) swap(s[i], s[n - i - 1]);
  return s;
}
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int i = 0;
  string m = s;
  while (i < k) {
    string r = reverseStr(s);
    string t = "";
    t = t + r[0];
    for (i = 1; i < n; i++) {
      string p = s.substr(i, n - i) + t;
      if (p < m) m = p;
      t = t + r[i];
    }
    if (m == s) {
      cout << m << endl;
      break;
    }
    i++;
  }
  cout << m << endl;
  return 0;
}
