#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
using namespace std;
vector<int> suffixArray(vector<int> s, int S = 256) {
  int n = s.size();
  int N = n + S;
  vector<int> sa(n), ra(n);
  for (int i = 0; i < n; i++) {
    sa[i] = i;
    ra[i] = s[i];
  }
  for (int k = 0; k < n; k ? k *= 2 : k++) {
    vector<int> nsa(sa), nra(n), cnt(N);
    for (int i = 0; i < n; i++) nsa[i] = (nsa[i] - k + n) % n;
    for (int i = 0; i < n; i++) cnt[ra[i]]++;
    for (int i = 1; i < N; i++) cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; i--) sa[--cnt[ra[nsa[i]]]] = nsa[i];
    int r = 0;
    for (int i = 1; i < n; i++) {
      if (ra[sa[i]] != ra[sa[i - 1]])
        r++;
      else if (ra[(sa[i] + k) % n] != ra[(sa[i - 1] + k) % n])
        r++;
      nra[sa[i]] = r;
    }
    ra = nra;
  }
  return sa;
}
const int INF = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  vector<int> s(2 * n + 1);
  for (int i = 0; i < n; ++i) s[i] = str[i];
  for (int i = n; i < 2 * n; ++i) s[i] = str[2 * n - 1 - i];
  s[2 * n] = '$';
  vector<int> sa = suffixArray(s);
  char mc = 'z';
  vector<int> cou(n, 1);
  for (int i = 0; i < n; ++i) {
    mc = min(mc, str[i]);
    if (i > 0 && str[i] == str[i - 1]) ++cou[i];
  }
  vector<pair<pair<int, int>, int>> offs;
  for (int i = 0; i < n; ++i) {
    if (str[i] == mc) {
      int len, loc;
      if (i < n - 1) {
        len = cou[i];
        loc = i + 1;
      } else {
        len = 2 * cou[i];
        loc = i + 1 + cou[i];
      }
      offs.push_back({{-len, -sa[loc]}, loc});
    }
  }
  sort(offs.begin(), offs.end());
  int act = -offs[0].first.first;
  for (; act < n && k > 1; --k) act *= 2;
  act = min(act, n);
  for (int j = 0; j < act; ++j) cout << mc;
  for (int j = 0; j < (n - act); ++j) cout << (char)s[offs[0].second + j];
  cout << '\n';
}
