#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0;
  bool f = 0;
  char c = getchar();
  while (c < '0' || c > '9') f |= c == '-', c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
int N, K;
char Min, Max, Ans[2 * 5000 + 5], str[2 * 5000 + 5];
char tmp[2 * 5000 + 5];
void Solve(char *S, int k) {
  memset(tmp, 0, sizeof(tmp));
  int Now = N, len = 0;
  while (Now >= 1 && S[Now] == Min) Now--, len++;
  while (k && len <= N - 1) len <<= 1, k--;
  if (len >= N) {
    for (int i = 1; i <= N; i++) Ans[i] = Min;
    puts(Ans);
    exit(0);
  }
  for (int i = 1; i <= len; i++) tmp[i] = Min;
  for (int i = len + 1; i <= N; i++) tmp[i] = S[Now--];
  for (int i = 1; i <= N; i++)
    if (tmp[i] < Ans[i]) {
      for (int j = 1; j <= N; j++) Ans[j] = tmp[j];
      return;
    } else if (tmp[i] > Ans[i])
      return;
}
int main() {
  N = read(), K = read();
  scanf("%s", str + 1);
  Min = 'z', Max = 'a';
  for (int i = 1; i <= N; i++) {
    Min = min(Min, str[i]);
    Max = max(Max, str[i]);
    str[2 * N - i + 1] = str[i];
    Ans[i] = 'z';
  }
  if (Min == Max) return puts(str + 1), 0;
  if (str[N] == Min) Solve(str, K);
  for (int i = N + 1; i <= 2 * N; i++)
    if (str[i] == Min) Solve(str + i - N, K - 1);
  puts(Ans + 1);
}
