#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string b = s;
  reverse(b.begin(), b.end());
  s += b;
  sort(b.begin(), b.end());
  vector<string> inputs;
  k--;
  k = min(k, 20LL);
  for (int i = 0; i < n + 1; ++i) {
    string c;
    for (int q = 0; q < n; ++q) {
      c.push_back(s[i + q]);
    }
    if (c[n - 1] != b[0]) {
      continue;
    }
    for (int t = 0; t < k - 1; ++t) {
      for (int j = n - 1; j >= 0; --j) {
        if (c[j] != b[0]) {
          string d;
          for (int t = 0; t < n; ++t) {
            d.push_back(c[t]);
          }
          for (int t = 0; t < n - 1 - j; ++t) {
            d.push_back(b[0]);
          }
          reverse(d.begin(), d.end());
          while (d.size() != n) {
            d.pop_back();
          }
          reverse(d.begin(), d.end());
          c = d;
          break;
        }
      }
    }
    if (k != 0) {
      for (int j = n - 1; j >= 0; --j) {
        if (c[j] != b[0]) {
          string d;
          for (int q = j + 1; q < n; ++q) {
            d.push_back(c[q]);
          }
          for (int q = n - 1; q >= 0 && d.size() != n; --q) {
            d.push_back(c[q]);
          }
          c = d;
          break;
        }
      }
    }
    inputs.push_back(c);
  }
  sort(inputs.begin(), inputs.end());
  cout << inputs[0] << endl;
}
