#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k;
char s[N];
int a[N << 1];
inline string get(int l, int r) {
  int t = k;
  for (int i = 1; i <= n; i++) a[i] = i;
  string ret = "";
  if (k == 1) {
    for (int i = n + 1; i <= n << 1; i++) a[i] = a[n * 2 + 1 - i];
    for (int i = 1; i <= n; i++) ret = ret + s[a[i + l - 1]];
    return ret;
  }
  if (r ^ n) {
    t--;
    for (int i = n + 1; i <= n << 1; i++) a[i] = a[n * 2 + 1 - i];
    for (int i = 1; i <= n; i++) a[i] = a[i + n + 1 - l];
    l += n - r;
  }
  while (t > 1) {
    for (int i = n + 1; i <= n << 1; i++) a[i] = a[n * 2 + 1 - i];
    for (int i = 1; i <= n; i++) a[i] = a[n + 1 + i - l];
    l = 2 * l - n - 1;
    t--;
  }
  for (int i = n + 1; i <= n << 1; i++) a[i] = a[n * 2 + 1 - i];
  for (int i = 1; i <= n; i++) ret = ret + s[a[i + l - 1]];
  return ret;
}
int main() {
  scanf("%d%d%s", &n, &k, s + 1);
  char low = 'z' + 1;
  int cnt = 0, mx = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] < low) {
      low = s[i];
      cnt = 1;
      mx = 1;
    } else if (s[i] == low)
      cnt++;
    else
      mx = std::max(cnt, mx), cnt = 0;
  }
  if (s[n] == low) {
    int x = n;
    while (x - 1 && s[x - 1] == low) x--;
    x = n - x + 1;
    if ((1 << min(31, k)) >= (n + x - 1) / x) {
      for (int i = 1; i <= n; i++) putchar(low);
      return 0;
    }
  }
  if ((1 << min(31, k - 1)) >= (n + mx - 1) / mx) {
    for (int i = 1; i <= n; i++) putchar(low);
    return 0;
  }
  string ans = "";
  ans += char('z' + 1);
  for (int i = 1, j; i <= n; i = j + 1) {
    while (i <= n && s[i] != low) i++;
    if (i > n) break;
    j = i;
    while (s[j + 1] == s[i]) j++;
    if (j - i + 1 == mx || j == n) {
      ans = min(ans, get(i, j));
    }
  }
  cout << ans;
  return 0;
}
