#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0,
                                                             flag = 0;
  string S, T;
  cin >> N >> K >> S;
  T = S;
  sort(T.begin(), T.end());
  for (long long int i = N - 1; i >= 0; i--) {
    if (S[i] == T[0])
      sum++;
    else
      break;
  }
  while (N > sum) {
    if (sum > 0)
      sum *= 2;
    else
      sum++;
    num++;
  }
  if (K >= num) {
    for (long long int i = 0; i < N; i++) cout << T[0];
    cout << "" << endl;
  } else {
    for (long long int i = 0; i < K - 1; i++) {
      vector<string> G(0, "");
      T = S;
      reverse(S.begin(), S.end());
      S += T;
      for (long long int j = 0; j < N + 1; j++) {
        T = S.substr(j, N);
        reverse(T.begin(), T.end());
        G.push_back(T);
      }
      sort(G.begin(), G.end());
      S = G[0];
    }
    vector<string> G(0, "");
    T = S;
    reverse(T.begin(), T.end());
    S += T;
    for (long long int i = 0; i < N + 1; i++) G.push_back(S.substr(i, N));
    sort(G.begin(), G.end());
    cout << G[0] << endl;
  }
}
