#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

string reverse_copy_string(string s) {
    string t;
    int n = s.size();
    for (int i = n-1; i >= 0; i--) {
        t.push_back(s[i]);
    }
    return t;
}

int main() {
    int n, k;
    cin >> n >> k;
    string s, t, u;
    cin >> s;
    t = reverse_copy_string(s);
    u = s + t;
    rep(i,min(14, k)) {
        t = u.substr(0,n);
        rep(j,n-1) {
            if (t > u.substr(j+1,n)) { 
                t = u.substr(j+1,n);
            }
        }
        s = reverse_copy_string(t);
        u = s + t;
    }
    cout << t << endl;
}
