#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int n, k, minn, len, maxlen, q[N];
string s, ans;
inline string reverse(string a) {
  string ret = a;
  for (int i = 0; i < a.length(); i++) ret[i] = a[a.length() - i - 1];
  return ret;
}
inline string get(int x) {
  string ret = s + reverse(s);
  if (x == n - 1) x += len - 1;
  ret = ret.substr(n - x + maxlen - 1, n - maxlen);
  return reverse(ret);
}
int main() {
  cin >> n >> k >> s;
  minn = 30;
  for (int i = 0; i < n; i++) minn = min(minn, s[i] - 'a');
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] - 'a' == minn)
      now++;
    else {
      if (now == 0 || now < len) continue;
      if (now > len) {
        len = now;
        q[0] = 0;
      }
      q[++q[0]] = i - 1;
      now = 0;
    }
  }
  if (now) now *= 2;
  if (now > len) {
    len = now;
    q[0] = 0;
  }
  if (now == len) q[++q[0]] = n - 1;
  maxlen = len;
  if (maxlen >= n) {
    char c = minn + 'a';
    for (int i = 1; i <= n; i++) cout << c;
    cout << endl;
    return 0;
  }
  for (int i = 1; i < k; i++) {
    maxlen *= 2;
    if (maxlen >= n) {
      char c = minn + 'a';
      for (int i = 1; i <= n; i++) cout << c;
      cout << endl;
      return 0;
    }
  }
  ans = get(q[1]);
  for (int i = 2; i <= q[0]; i++) ans = min(ans, get(q[i]));
  char c = minn + 'a';
  for (int i = 1; i <= maxlen; i++) cout << c;
  cout << ans << endl;
  return 0;
}
