#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  string s;
  cin >> n >> k >> s;
  string t = s;
  reverse(t.begin(), t.end());
  string mi = s;
  s += t;
  for (int i = 0; i < n; i++) {
    mi = min(mi, s.substr(i,n));
  }
  k--;
  while (k--) {
    char c = mi[0];
    int cs = 0;
    while (cs < n && mi[cs] == c) cs++;
    if (cs == n) break;
    mi = (mi.substr(0,cs)+mi).substr(0,n);
  }
  cout << mi << endl;
}
