#include <bits/stdc++.h>
using namespace std;
const int n = 10050;
int N, K;
string S, best;
int cnt[n];
int main() {
  cin >> N >> K;
  cin >> S;
  best = S;
  string tmp = S;
  reverse(tmp.begin(), tmp.end());
  S += tmp;
  K = min(K, 15);
  char minc = 'z';
  for (char c : S) minc = min(minc, c);
  if (S[0] == minc) cnt[0] = 1;
  int bestc = 0;
  vector<int> bst;
  for (int i = 1; i < 2 * N; i++) {
    if (S[i] == minc) cnt[i] = cnt[i - 1] + 1;
    if (cnt[i] > bestc) {
      bst.clear();
      bestc = cnt[i];
    }
    if (cnt[i] == bestc) bst.push_back(i);
  }
  K--;
  long long cntB = bestc;
  for (int i = 0; i < K; i++) cntB *= 2;
  cntB = min(cntB, (long long)N);
  vector<string> res;
  for (int i = 0; i < ((int)(bst).size()); i++) {
    if (2 * N - bst[i] - 1 < N - cntB) continue;
    string cur = "";
    for (int j = 0; j < cntB; j++) {
      cur.push_back(minc);
    }
    for (int j = 1; j <= N - cntB; j++) {
      cur.push_back(S[bst[i] + j]);
    }
    res.push_back(cur);
  }
  sort(res.begin(), res.end());
  cout << res[0] << endl;
  return 0;
}
