#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	for(int i = 0;i < min(K,100);i++) {
		string cnt = S;
		reverse(cnt.begin(),cnt.end());
		string tmp = S;
		tmp += cnt;
		string ret2 = S;
		for(int j = 0;j < N + 1;j++) {
			string cnt2 = tmp.substr(j,N);
			ret2 = min(ret2,cnt2);
		}
		reverse(ret2.begin(),ret2.end());
		S = ret2;
	}
	reverse(S.begin(),S.end());
	cout << S << endl;
}