#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    string t = s;
    reverse(t.begin(), t.end());
    string u = s + t;

    string x = s;
    rep(i, n+1) {
        string y = u.substr(i, n);
        if (y < x) x = y;
    }
    if (k == 1) {
        cout << x << endl;
        return 0;
    }

    int cnt = 1;
    rep(i, n) {
        if (i == 0) continue;
        if (x[0] == x[i]) cnt++;
        else break;
    }

    string y = x.substr(cnt, n - cnt);

    k--;
    while (cnt < n && k > 0) {
        cnt *= 2;
        k--;
    }

    string ans;
    if (k >= n) ans = string(n, x[0]);
    else ans = string(cnt, x[0]) + string(y.begin(), y.begin() + n - cnt);
    cout << ans << endl;
}
