#include <bits/stdc++.h>
const int MAXN = 5010;
std::string get(std::string buf, int K) {
  int L = buf.size(), at = L - 1;
  while (~at && buf[at] == buf[L - 1]) --at;
  int cnt = std::min((long long)(L - at - 1) << K, (long long)L);
  return std::string(cnt, buf[L - 1]) +
         std::string(buf.rbegin() + L - at - 1,
                     buf.rbegin() + L - at + L - cnt - 1);
}
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(0);
  std::string t, ans;
  int N, K;
  std::cin >> N >> K >> t;
  ans = t;
  if (K > 20) ans = std::string(N, *std::min_element(t.begin(), t.end()));
  t = t + std::string(t.rbegin(), t.rend());
  for (int i = 0; i < N; ++i) {
    std::string res = get(t.substr(i, N), K - 1);
    if (res < ans) ans = res;
  }
  std::cout << ans << std::endl;
  return 0;
}
