#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
char s[N], ans[N];
int n, k;
int check(int l) {
  for (int i = 0; i < n; i++) {
    if (s[i + l] != ans[i]) {
      return s[i + l] < ans[i];
    }
  }
  return 0;
}
void cov(int l) {
  for (int i = 0; i < n; i++) ans[i] = s[i + l];
}
int main() {
  cin >> n >> k;
  scanf("%s", s);
  for (int i = n; i < 2 * n; i++) s[i] = s[2 * n - 1 - i];
  cov(1);
  for (int i = 1; i < n; i++)
    if (check(i)) cov(i);
  int cnt = 0, cnt1 = 0;
  for (int i = 0; i < n; i++) {
    if (ans[i] != ans[0])
      break;
    else
      cnt++;
  }
  cnt1 = cnt;
  while (k > 1 && cnt < n) k--, cnt <<= 1;
  cnt = min(cnt, n);
  for (int i = 1; i <= cnt; i++) putchar(ans[0]);
  for (int i = 0; i < n - cnt; i++) putchar(ans[i + cnt1]);
  cout << endl;
}
