#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// AtCoder Grand Contest 037
int main(){

    int N, K; cin >> N >> K;
    chmin(K, 15);

    string S; cin >> S; S += S;
    reverse(S.begin() + N, S.end());

    char need = 'z';
    rep(i, N)chmin(need, S[i]);

    string ans;
    rep(i, N)ans += 'z';

    function<void(string)> calc = [&](string s){
        reverse(all(s));
        int cnt = 0;
        rep(i, N){
            if(s[i] == need)cnt++;
            else break;
        }
        if(cnt == 0)return;
        if(((long long)cnt << (K - 1)) >= N){
            chmin(ans, string(N, need));
            return;
        } else {
            int sz = cnt << (K - 1);
            string tmp(sz, need);
            tmp += s.substr(cnt, N - sz);
            chmin(ans, tmp);
        }
    };

    rep(i, N + 1){
        string T = S.substr(i, N);
        calc(T);
    }

    cout << ans << endl;
    return 0;

}