#include <bits/stdc++.h>
using namespace std;
int n, K;
char S[10010], Ans[10010];
int L = 0, H;
int G = 0;
char c = 'z';
char ch[10010];
int sum[10010];
inline void solve() {
  for (register int i = 1; i <= n - L; ++i) ch[i] = ch[L - H + i];
  for (register int i = n - L + 1; i <= n; ++i) ch[i] = c;
  reverse(ch + 1, ch + n + 1);
}
int main() {
  scanf("%d%d", &n, &K);
  scanf("%s", S + 1);
  for (register int i = 1; i <= n; ++i) Ans[i] = c;
  for (register int i = 1; i <= n; ++i)
    if (S[i] < c) c = S[i];
  int at;
  bool flag = false;
  for (register int i = 1; i <= n; i = at)
    if (S[i] == c) {
      at = i;
      while (at <= n && S[at] == c) at++;
      if (at == n + 1) G = at - i;
      if (at - i >= L) {
        L = at - i;
        if (at == n + 1) flag = true;
      }
    } else
      at = i + 1;
  H = L;
  if (G * 2 >= H) {
    H = G;
    flag = true;
  }
  if (!flag) K--;
  for (register int i = 1; i <= K; ++i) {
    L *= 2;
    if (L >= n) {
      for (register int j = 1; j <= n; ++j) printf("%c", c);
      return 0;
    }
  }
  if (flag) {
    for (register int i = 1; i <= n; ++i) ch[i] = S[i];
    solve();
    bool Ha = false;
    for (register int i = 1; i <= n; ++i) {
      if (Ha == false && ch[i] > Ans[i]) break;
      if (ch[i] < Ans[i]) Ha = true;
      if (Ha) Ans[i] = ch[i];
    }
  } else {
    for (register int i = n + 1; i <= 2 * n; ++i) S[i] = S[2 * n + 1 - i];
    sum[0] = 0;
    for (register int i = 1; i <= 2 * n; ++i) {
      sum[i] = sum[i - 1];
      if (S[i] == c) sum[i]++;
    }
    for (register int i = n; i <= 2 * n; ++i)
      if (sum[i] - sum[i - H] == H) {
        for (register int j = 1; j <= n; ++j) ch[j] = S[i - n + j];
        solve();
        bool Ha = false;
        for (register int i = 1; i <= n; ++i) {
          if (Ha == false && ch[i] > Ans[i]) break;
          if (ch[i] < Ans[i]) Ha = true;
          if (Ha) Ans[i] = ch[i];
        }
      }
  }
  for (register int i = 1; i <= n; ++i) printf("%c", Ans[i]);
  return 0;
}
