#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
long long n, k;
string get(string s, long long k) {
  if (k == 0) return s;
  long long n = s.size();
  while (k > 1) {
    long long take = 1;
    while (take < n && s[n - take - 1] == s[n - 1]) take++;
    string t = "";
    for (long long i = 0; i < n - take; i++) t += s[take + i];
    for (long long i = 0; i < take; i++) t += s[n - i - 1];
    s = t;
    k--;
  }
  long long take = 1;
  while (take < n && s[n - take - 1] == s[n - 1]) take++;
  string t = "";
  for (long long i = 0; i < take; i++) t += s[n - take + i];
  for (long long i = 0; i < n - take; i++) t += s[n - i - 1];
  return t;
}
void solve() {
  string s, a, p;
  cin >> n >> k >> s;
  string ans = s;
  a = s;
  reverse(a.begin(), a.end());
  p = s + a;
  k = min(k, 15ll);
  for (long long i = 0; i < n; ++i) {
    string cur = "";
    for (long long j = 0; j < n; ++j) cur += p[i + j];
    ans = min(ans, get(cur, k - 1));
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  long long t = 1;
  for (long long i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
