#include <bits/stdc++.h>
using namespace std;
const int oo = 2139063143;
const int N = 1010000;
const int P = 1000000007;
const double eps = 1e-7;
template <typename T>
inline void sc(T &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
template <typename T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void pr(T x) {
  print(x), putchar('\n');
}
template <typename T1, typename T2>
void chkmax(T1 &A, T2 B) {
  A = A >= B ? A : B;
}
template <typename T1, typename T2>
void chkmin(T1 &A, T2 B) {
  A = A <= B ? A : B;
}
int n, k;
char s[N];
bool check(int x, int y) {
  for (int i = 1; i <= n; i++)
    if (s[x + i - 1] != s[y + i - 1]) return s[x + i - 1] < s[y + i - 1];
  return 0;
}
int main() {
  sc(n), sc(k);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) s[n * 2 - i + 1] = s[i];
  int p = 1;
  for (int i = 2; i <= n + 1; i++)
    if (check(i, p)) p = i;
  int len = 1, f = 1 << (k - 1);
  while (len < n && s[p + len] == s[1]) ++len;
  if (k >= 15 || len * f >= n) {
    for (int i = 1; i <= n; i++) putchar(s[p]);
    return 0;
  }
  for (int i = 1; i <= len * f; i++) putchar(s[p]);
  int las = n - len * f;
  for (int i = 1; i <= las; i++) putchar(s[p + len + i - 1]);
  return 0;
}
