#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  char c = 'z';
  for (auto &p : s) c = min(c, p);
  s += t;
  int mx = 0;
  for (int i = 0, cur = 0; i < s.length(); i++) {
    if (s[i] == c)
      cur++;
    else
      cur = 0;
    mx = max(mx, cur);
  }
  if (k >= 14 || (mx << k - 1) >= n) {
    for (int i = 0; i < n; i++) cout << c;
    return 0;
  }
  string ans;
  for (int i = 0; i <= n; i++) {
    if (k > 1) {
      int j = i + n - 1;
      int cnt = 0;
      for (int k = j; k >= i && s[k] == c; k--) cnt++;
      if (cnt < mx) continue;
      int d = (mx << k - 1) - mx;
      int f = i + d;
      string t = s.substr(f, n);
      for (int l = n - 1; l >= n - (mx << k - 1); l--) t[l] = c;
      reverse(t.begin(), t.end());
      if (ans.empty() || t < ans) {
        ans = t;
      }
    } else {
      string t = s.substr(i, n);
      if (ans.empty() || t < ans) {
        ans = t;
      }
    }
  }
  cout << ans;
  return 0;
}
