#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc;
int ny;
inline char gc() { return getchar(); }
inline int read() {
  int x = 0;
  for (ny = 1; nc = gc(), (nc < 48 || nc > 57) && nc != EOF;)
    if (nc == 45) ny = -1;
  if (nc < 0) return nc;
  for (x = nc - 48; nc = gc(), 47 < nc && nc < 58 && nc != EOF;
       x = (x << 3) + (x << 1) + (nc ^ 48))
    ;
  return x * ny;
}
int n, k, len, l[MAXN];
string s, t, ans;
char c;
int main() {
  n = read(), k = read(), cin >> s, n = s.size();
  c = 'z';
  for (int i = n - 1; i >= 0; i--) s.push_back(s[i]), c = min(c, s[i]);
  if (k >= 15) {
    for (int i = 1; i <= n; i++) putchar(c);
    return 0;
  }
  if (k == 1) {
    while (1)
      ;
    ans = s.substr(0, n);
    for (int i = 1; i <= n; i++) ans = min(ans, s.substr(i, n));
    cout << ans;
    return 0;
  }
  int Mx = 0;
  k--;
  for (int i = 0; i <= 2 * n - 1; i++)
    Mx = max(Mx, i == 0 ? l[i] = 1 : s[i] == c ? l[i] = l[i - 1] + 1 : 0);
  if (Mx << k >= n) {
    for (int i = 1; i <= n; i++) putchar(c);
    return 0;
  }
  int len = Mx << k;
  len = n - len;
  int opt = 0;
  for (int i = 0; i <= 2 * n - 1; i++)
    if (l[i] == Mx) {
      if (i - Mx + 1 >= len) {
        t = s.substr(0, i - Mx + 1), reverse(t.begin(), t.end());
        if (!opt)
          ans = t, opt = 1;
        else
          ans = min(ans, t);
      }
    }
  for (int i = 1; i <= Mx << k; i++) putchar(c);
  for (int i = 0; i <= len - 1; i++) cout << ans[i];
  return 0;
}
