#include <bits/stdc++.h>
using namespace std;
using cat = long long;
string min_str(string S, int K) {
  if (K == 0) return S;
  int N = S.length();
  int occ = 0;
  while (occ < N && S[N - 1 - occ] == S[N - 1]) occ++;
  int occ0 = occ;
  while (K > 1) {
    occ *= 2;
    occ = min(occ, N);
    K--;
  }
  if (occ == N) {
    string ret = "";
    for (int i = 0; i < N; i++) ret += S[N - 1];
    return ret;
  }
  int r = N - occ;
  string X = S.substr(N - occ0 - r, r);
  for (int i = 0; i < occ; i++) X += S[N - 1];
  string Xr = X;
  reverse(begin(Xr), end(Xr));
  string Y = X + Xr;
  vector<int> cand_pos;
  int max_occ = -1;
  for (int i = 0; i <= N; i++)
    if (Y[i] == S[N - 1] && (i == 0 || Y[i - 1] != S[N - 1])) {
      int cur_occ = 0;
      while (i + cur_occ < 2 * N && S[N - 1] == Y[i + cur_occ]) cur_occ++;
      if (max_occ < cur_occ) {
        cand_pos = {};
        max_occ = cur_occ;
      }
      if (max_occ == cur_occ) cand_pos.push_back(i);
    }
  if (cand_pos.size() > 3) cand_pos.resize(3);
  string ret = X;
  for (int pos : cand_pos) ret = min(ret, Y.substr(pos, N));
  return ret;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int N, K;
  string S;
  cin >> N >> K >> S;
  string ans = S;
  char min_char = 'z';
  for (int i = 0; i < N; i++) min_char = min(min_char, S[i]);
  if (S[N - 1] == min_char) ans = min(ans, min_str(S, K));
  string Sr = S;
  reverse(begin(Sr), end(Sr));
  string X = S + Sr;
  for (int i = 1; i < N; i++)
    if (X[i] == min_char && X[i - 1] != min_char)
      ans = min(ans, X.substr(i, N));
  for (int i = 0; i < N; i++)
    if (X[N + i] == min_char && (i == N - 1 || X[N + i + 1] != min_char)) {
      string Y = X.substr(i + 1, N);
      ans = min(ans, min_str(Y, K - 1));
    }
  cout << ans << "\n";
  return 0;
}
