#include <bits/stdc++.h>
using namespace std;
const int max_n = 5555, inf = 1000111222;
int n, k;
string s;
string getr(const string &s, int pos) {
  return {s.rbegin() + s.length() - 1 - pos,
          s.rbegin() + s.length() - 1 - pos + n};
}
string one_step(const string &s) {
  string rs = s;
  reverse(rs.begin(), rs.end());
  string t = s + rs;
  string res = s;
  for (int i = 1; i <= n; ++i) {
    res = min(res, t.substr(i, n));
  }
  return res;
}
int main() {
  freopen("input.txt", "r", stdin);
  cin >> n >> k >> s;
  --k;
  char mn = s[0];
  for (char c : s) {
    mn = min(mn, c);
  }
  if (k) {
    string rs = s;
    reverse(rs.begin(), rs.end());
    int mx = 0, pos = 0;
    string t = s + rs;
    for (int i = 0; i < t.length(); ++i) {
      int st = i;
      while (i < t.length() && t[i] == mn) {
        ++i;
      }
      int cnt = i - st;
      if (cnt == 0) {
        continue;
      }
      if (i >= n && (mx < cnt || mx == cnt && getr(t, pos) > getr(t, i - 1))) {
        pos = i - 1;
        mx = cnt;
      }
    }
    s = getr(t, pos);
    reverse(s.begin(), s.end());
    --k;
    mx = min(mx, n);
    while (k--) {
      string rs = s;
      reverse(rs.begin(), rs.end());
      string t = s + rs;
      s = getr(t, s.length() + mx - 1);
      reverse(s.begin(), s.end());
      mx *= 2;
      mx = min(mx, n);
      if (mx == n) {
        break;
      }
    }
  }
  cout << one_step(s) << endl;
  return 0;
}
