#include <bits/stdc++.h>
using namespace std;
int N, K;
string S;
string solve(string &s, int rest, int malen) {
  if (rest == 1) {
    string p = s;
    reverse(p.begin(), p.end());
    string r = s.substr(s.size() - malen, malen);
    r += r;
    r += p.substr(malen, s.size() - 2 * malen);
    return r;
  }
  string t = "";
  for (int i = 0; i < min(N, 2 * malen); i++) t += s.back();
  if (t.size() == N) return t;
  string r = s.substr(malen, N - (2 * malen));
  r += t;
  return solve(r, rest - 1, 2 * malen);
}
int main() {
  cin >> N >> K;
  cin >> S;
  vector<string> cand;
  if (K == 1) {
    string T = S;
    reverse(T.begin(), T.end());
    T = S + T;
    for (int i = 0; i <= N; i++) cand.push_back(T.substr(i, N));
  } else {
    vector<string> v;
    int mi = 30;
    for (int i = 0; i < N; i++) {
      mi = min(mi, S[i] - 'a');
    }
    string T = S;
    reverse(T.begin(), T.end());
    T = S + T;
    int malen = 1;
    int len = 0;
    for (int i = 0; i < T.size(); i++) {
      if (mi == T[i] - 'a')
        len++;
      else {
        malen = max(malen, len);
        len = 0;
      }
    }
    malen = max(malen, len);
    len = 0;
    for (int i = 0; i < T.size(); i++) {
      if (mi == T[i] - 'a')
        len++;
      else
        len = 0;
      if (len == malen && i - N + 1 >= 0) {
        string s = T.substr(i - N + 1, N);
        v.push_back(s);
      }
    }
    for (int i = 0; i < v.size(); i++) {
      string s = solve(v[i], min(K - 1, 35), malen);
      cand.push_back(s);
    }
  }
  sort(cand.begin(), cand.end());
  cout << cand[0] << endl;
  return 0;
}
