#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii; using namespace std;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(){
  int N, K, m=1; cin >> N >> K; string s; cin >> s;
  if (N==1) {cout << s << endl; return 0;}

  int bc = 1e5; bool best = false;
  rep(i, 0, N) bc = min((int)s[i], bc);
  
  string worst, bestest;
  rep(i, 0, N) worst += 'z';
  rep(i, 0, N) bestest += 'a';

  while (!best && K>m) {
    m++;
    int longest=1, nw=0, wh=-1; // 最長、今、どこ
    vector<int> w, c; // 最長の位置

    rep(i, 0, N) {
      if (bc == s[i]) {
        nw++; if (wh<0) wh=2*N-1-i;
        //cout << i << " ";
      } else {
        //cout << "["<<longest<<"_"<<nw<<"_"<<wh<<"]";
        if (longest == nw) {w.push_back(wh);}
        else if (longest < nw) {w=c; w.push_back(wh); longest=nw;}
        nw=0; wh=-1;
      }
      //cout << "(" << wh << ":"<< w.size() << ") ";
    }

    // N文字目はもう一度
      if (bc == s[N-1]) {
        nw++; if (wh<0) wh=N-1;
      }
      if (longest == nw) w.push_back(wh);
      else if (longest < nw) {w=c; w.push_back(wh); longest=nw;}
      nw=0; wh=-1;

    if (longest >= N) {best = true; continue;}

    string u; u+=s;
    repM(i, 0, N) u+=s[i];
    
    //cout << u << endl;
    //rep(i, 0, w.size()) cout << w[i] << " ";
    if (w.size() == 1) s = u.substr(w[0]-(N-1),N);
    else {
      string s2; s = bestest;
      for(int wh : w) {
        s2 = u.substr(wh-(N-1),N);
        //reverse(all(s2));
        if (s< s2) s = s2;
      }
      //reverse(all(s));
    }
    //s = "abdecrwgeb";
    
    //cout << s << endl;
  }

  if (best) {rep(i, 0, N) cout << (char)bc; cout << endl;}
  else {
    string u; u+=s;
    repM(i, 0, N) u+=s[i];
    //s = u.substr(wh-(N-1),N);
    //int longest=0, nw=0, wh=0;
    string t, v; v=u.substr(0,N);
    rep(i, 0, N+1) {
      t = u.substr(i,N);
      if (t < v) v=t;
    }
    cout << v << endl;
  }
}