#include <bits/stdc++.h>
char s[10009 + 10], nou[10009 + 10];
int ind[10009];
int n;
bool cmp(const int &a, const int &b) {
  int i = 0;
  while (i < n - 1 && s[a + i] == s[b + i]) i++;
  return s[a + i] < s[b + i];
}
int main() {
  int k;
  fscanf(stdin, "%d%d ", &n, &k);
  fgets(s, 10009 + 5, stdin);
  if (k == 0) {
    fputs(s, stdout);
    return 0;
  }
  for (int i = n, j = n - 1; i < 2 * n; i++, j--) s[i] = s[j];
  for (int i = 0; i < n; i++) ind[i] = i;
  std::sort(ind, ind + n, cmp);
  if (k > 15) k = 15;
  int poz = ind[0];
  while (k > 1) {
    for (int i = n - 1, j = 2 * n - poz - 1; i >= 0; i--, j--) nou[i] = s[j];
    for (int i = n, j = n - 1; i < 2 * n; i++, j--) s[i] = s[j] = nou[j];
    k--;
  }
  std::sort(ind, ind + n, cmp);
  for (int i = 0; i < n; i++) fputc(s[i + ind[0]], stdout);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
