#include <bits/stdc++.h>
using namespace std;
int n, bestPos;
string s;
bool compare(int x, bool reversed) {
  for (int i = 0; i < n; i++) {
    if (!reversed && s[i + x] != s[i + bestPos]) {
      return s[i + x] < s[i + bestPos];
    }
    if (reversed && s[n - 1 - i + x] != s[n - 1 - i + bestPos]) {
      return s[n - 1 - i + x] < s[n - 1 - i + bestPos];
    }
  }
  return true;
}
int main() {
  int k;
  cin >> n >> k >> s;
  for (int i = 0; i < k; i++) {
    string t = s;
    reverse(t.begin(), t.end());
    s += t;
    bestPos = 0;
    for (int j = 0; j <= n; j++) {
      if (compare(j, i != k - 1)) bestPos = j;
    }
    string best = s.substr(bestPos, n);
    if (best == s) {
      cout << best << endl;
      return 0;
    }
    s = best;
  }
  cout << s << endl;
  return 0;
}
