#include <bits/stdc++.h>
using namespace std;
int n, K;
string s, ans;
char mn;
void get_S(string& s) {
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
}
void solve(string s, int K) {
  int now = 0;
  while (now < n && s[n - now - 1] == mn) now++;
  for (; K > 1; K--) {
    get_S(s);
    s = s.substr(now, n);
    now <<= 1;
  }
  get_S(s);
  s = s.substr(n - now, n);
  ans = min(ans, s);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> K;
  cin >> s;
  mn = 'z';
  for (int i = 0; i < n; i++) mn = min(mn, s[i]);
  if (K > 13) {
    for (int i = 0; i < n; i++) putchar(mn);
    puts("");
    return 0;
  }
  get_S(s);
  ans += 127;
  int mxlen = 0;
  vector<int> w;
  for (int i = 0; i < 2 * n; i++) {
    if (i <= n && K == 1) ans = min(ans, s.substr(i, n));
    if (i > 0 && s[i - 1] == mn) continue;
    int len = 0;
    while (i + len < 2 * n && s[i + len] == mn) len++;
    if (len > mxlen) w.clear(), mxlen = len;
    if (len == mxlen && i + len >= n) w.push_back(i + len);
  }
  if (K > 1)
    for (auto x : w) {
      string t = s.substr(x - n, n);
      solve(t, K - 1);
    }
  cout << ans << '\n';
  return 0;
}
