#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  string U = S;
  reverse(S.begin(), S.end());
  U += S;
  reverse(S.begin(), S.end());
  char smallest = 'z';
  for (int i = 0; i < N; ++i) {
    smallest = min(smallest, S[i]);
  }
  int length = 0;
  int cnt = 0;
  for (int i = 0; i < N * 2; ++i) {
    if (U[i] == smallest) {
      cnt++;
    } else {
      length = max(length, cnt);
      cnt = 0;
    }
  }
  length = max(length, cnt);
  int left = length;
  for (int i = 0; i < K - 1; ++i) {
    left *= 2;
    if (left >= N) {
      for (int j = 0; j < N; ++j) {
        cout << smallest;
      }
      cout << "\n";
      return 0;
    }
  }
  for (int i = 0; i < left - length; ++i) {
    cout << smallest;
  }
  left = N - left;
  string ans = U.substr(0, length + left);
  for (int i = 0; i <= N * 2 - length - left; ++i) {
    string sub = U.substr(i, length + left);
    ans = min(ans, sub);
  }
  cout << ans << "\n";
  return 0;
}
