#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char mic = 'z';
  for (int i = 0; i < (n); i++) {
    mic = min(mic, s[i]);
  }
  string t = s;
  reverse((t).begin(), (t).end());
  s += t;
  if (k == 1) {
    string mis(1, 'z' + 1);
    for (int i = 0; i < (n + 1); i++) {
      mis = min(mis, s.substr(i, n));
    }
    cout << mis << endl;
    return 0;
  } else if (k >= 14) {
    string ans(n, mic);
    cout << ans << endl;
    return 0;
  }
  vector<long long> c(2 * n, 0);
  c[0] = (s[0] == mic ? 1 : 0);
  for (int i = (1); i < (2 * n); i++) {
    if (s[i] == mic)
      c[i] = c[i - 1] + 1;
    else
      c[i] = 0;
  }
  long long maxc = c[n - 1];
  for (int i = (n); i < (2 * n); i++) {
    maxc = max(maxc, c[i]);
  }
  if ((maxc << (k - 1)) >= n) {
    string ans(n, mic);
    cout << ans << endl;
    return 0;
  }
  reverse((s).begin(), (s).end());
  string ans(1, 'z' + 1);
  int len = n - maxc * ((1 << (k - 1)) - 1);
  for (int i = 0; i < (2 * n - len + 1); i++) {
    ans = min(ans, s.substr(i, len));
  }
  string ans2(maxc * ((1 << (k - 1)) - 1), mic);
  ans = ans2 + ans;
  cout << ans << endl;
  return 0;
}
