#include <algorithm>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  string ans = s;
  for(int j = 0; j < min(N,K); ++j){
    string t = s;
    reverse(t.begin(), t.end());
    s += t;
    for(int i = 0; i < N; ++i){
      string x = s.substr(i,N);
      //cerr << i << " " << x << endl;
      ans = min(ans,x);
    }
    //cerr << ans << endl;
    reverse(ans.begin(), ans.end());
    s = ans;
    string tmp = s;
    sort(tmp.begin(), tmp.end());
    if(tmp[0] == tmp.back())
      break;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}
