#include <bits/stdc++.h>
void reverse(char *in, char *out) {
  int i, j = 0;
  int len = strlen(in);
  for (i = len - 1; i >= 0; i--) {
    out[j] = in[i];
    j++;
  }
  out[j] = 0;
}
void searchMin(char *in, char *out, int N) {
  int i;
  char *sub = (char *)calloc(N + 1, sizeof(char));
  char *tmp = (char *)calloc(N + 1, sizeof(char));
  memcpy(sub, in, N);
  for (i = 1; i < N; i++) {
    memcpy(tmp, in + i, N);
    if (strcmp(tmp, sub) < 0) {
      memcpy(sub, tmp, N);
    }
  }
  strcpy(out, sub);
  free(sub);
  free(tmp);
}
int main(void) {
  int N;
  char *S, *U, *MIN;
  char *S_temp;
  int K;
  int count = 1;
  scanf("%d %d", &N, &K);
  S = (char *)calloc(N + 1, sizeof(char));
  S_temp = (char *)calloc(N + 1, sizeof(char));
  U = (char *)calloc(N * 2 + 1, sizeof(char));
  scanf("%s", S);
  while (count < K) {
    reverse(S, S_temp);
    strcpy(U, S);
    strcat(U, S_temp);
    searchMin(U, S_temp, N);
    reverse(S_temp, S);
    count++;
  }
  reverse(S, S_temp);
  strcpy(U, S);
  strcat(U, S_temp);
  searchMin(U, S, N);
  printf("%s\n", S);
  free(S);
  free(S_temp);
  free(U);
  return 0;
}
