#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t INF = 1e18;
double EPS = 0.00000001;
int main() {
  int64_t n, k;
  string s;
  cin >> n >> k >> s;
  string t = s;
  reverse(t.begin(), t.end());
  string u = s;
  reverse(u.begin(), u.end());
  s = s + t;
  for (int64_t i = 0; i <= n + 1; i++) {
    string tmp = s.substr(i, n);
    reverse(tmp.begin(), tmp.end());
    u = min(u, tmp);
  }
  int64_t cnt = 0;
  char a = u[0];
  string pre = "";
  for (int64_t i = 0; a == u[i]; i++) {
    cnt++;
    pre.push_back(u[i]);
  }
  int64_t i = 0;
  while (cnt <= n && i < k - 1) {
    cnt <<= 1LL;
    i++;
  }
  if (cnt > n) {
    for (int64_t i = 0; i < n; i++) {
      cout << a;
    }
    cout << endl;
    return 0;
  } else {
    for (int64_t i = 0; i < cnt; i++) {
      cout << a;
    }
    int64_t i = 0;
    while (a == u[i]) i++;
    while (i < n - (cnt - (int64_t)pre.size())) {
      cout << u[i];
      i++;
    }
    cout << endl;
    return 0;
  }
  return 0;
}
