#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const long long mod = 998244353;
const double eps = 1e-7;
template <class T>
void read(T &a) {
  int f = 1;
  a = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    a = (a << 3) + (a << 1) + ch - '0';
    ch = getchar();
  }
  a *= f;
}
int n, k;
char s[maxn], ans[maxn], t[maxn];
bool cmp(char *a, char *b) {
  for (int i = (1); i <= (n); ++i) {
    if (a[i] < b[i]) return 1;
    if (a[i] > b[i]) return 0;
  }
  return 0;
}
signed main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s + 1);
  for (int i = (1); i <= (n); ++i) ans[i] = s[i];
  for (int i = (2); i <= (n); ++i) {
    int cnt = 0;
    for (int j = (i); j <= (n); ++j) t[++cnt] = s[j];
    for (int j = (n); j >= (1); --j) {
      t[++cnt] = s[j];
      if (cnt == n) break;
    }
    if (cmp(t, ans))
      for (int j = (1); j <= (n); ++j) ans[j] = t[j];
  }
  for (int i = (1); i <= (k - 1); ++i) {
    int cnt = 1;
    for (int j = (2); j <= (n); ++j)
      if (ans[j] == ans[j - 1])
        cnt++;
      else
        break;
    if (cnt == n) break;
    for (int j = (n); j >= (cnt + 1); --j) ans[j] = ans[j - cnt];
  }
  for (int i = (1); i <= (n); ++i) putchar(ans[i]);
  return 0;
}
