#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
string go(string s, int h) {
  string ret;
  for (int i = h; i < n; i++) {
    ret += s[i];
  }
  for (int i = n - 1; i >= n - h; i--) {
    ret += s[i];
  }
  return ret;
}
string calc(string s, int k) {
  if (k == 0) return s;
  int cnt = 0;
  char c = s.back();
  while (cnt < n && s[n - cnt - 1] == c) {
    cnt++;
  }
  if (cnt == n) return s;
  while (k > 1) {
    cnt *= 2;
    k--;
    if (cnt >= n) {
      return string(n, c);
    }
  }
  while (s.back() == c) {
    s.pop_back();
  }
  s += string(cnt, c);
  s = s.substr((int)s.size() - n);
  int r = s.size() - 1;
  while (s[r] == c) r--;
  r++;
  return go(s, r);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> s;
  string ans = s;
  ans = min(s, calc(s, k));
  for (int i = 0; i < n; i++) {
    string cur = go(s, i);
    ans = min(ans, calc(cur, k - 1));
  }
  cout << ans << endl;
}
