#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  int f = 0;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
const int N = 5005;
int n, K, mn = 233, mx;
char s[N], t[N], ans[N];
void doit(int K, int l, int r) {
  for (int T = (1); T <= (K - 1); T++) {
    for (int i = (1); i <= (l - 1); i++) t[i] = t[i + n - (l - 1)];
    reverse(t + l, t + n + 1);
    if (r < n)
      l = n - (r - l), r = n;
    else
      l = 2 * l - n;
    if (l <= 0) return;
  }
  for (int i = (l); i <= (n); i++) t[i - l + 1] = t[i];
  reverse(t + n - l + 2, t + n + 1);
}
int main() {
  read(n), read(K);
  K = min(K, 13);
  scanf("%s", s + 1);
  memcpy(ans, s, sizeof s);
  for (int i = (1); i <= (n); i++) mn = min(mn, (int)s[i]);
  for (int l = 1, r; l <= n; l++)
    if (s[l] == mn) {
      for (r = l; r < n && s[r + 1] == mn; r++)
        ;
      if (r - l < mx && r < n) continue;
      mx = max(mx, r - l);
      memcpy(t, s, sizeof s);
      doit(K, l, r);
      if (strcmp(t + 1, ans + 1) < 0) memcpy(ans, t, sizeof t);
      l = r;
    }
  puts(ans + 1);
  return 0;
}
