#include <bits/stdc++.h>
using namespace std;
const long long P = 1e9 + 7;
const int N = 10005;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
char s[N];
int n, k, cont[N];
int main() {
  cin >> n >> k;
  cin >> (s + 1);
  char a = 'z';
  for (int i = (1); i <= (n); ++i) a = min(a, s[i]);
  for (int i = (1); i <= (n); ++i) s[n * 2 + 1 - i] = s[i];
  int l = 0;
  cont[0] = 0;
  for (int i = (1); i <= (2 * n); ++i) {
    cont[i] = s[i] == a ? cont[i - 1] + 1 : 0;
    l = max(l, cont[i]);
  }
  string ans;
  ans += (a + 1);
  if (l > (n >> k - 1)) {
    for (int i = (1); i <= (n); ++i) ans += a;
    cout << ans << endl;
    return 0;
  }
  for (int i = (n); i <= (2 * n); ++i)
    if (cont[i] == l) {
      string tmp = "";
      int l1 = min(l << k - 1, n), beg, end;
      end = i - l, beg = end - (n - l1) + 1;
      for (int j = (1); j <= (l1); ++j) tmp += a;
      if (end)
        for (int j = (end); j >= (beg); --j) tmp += s[j];
      ans = min(ans, tmp);
    }
  cout << ans << endl;
  return 0;
}
