#include <bits/stdc++.h>
using namespace std;
struct SuffixArray {
  vector<int> sa, lcp;
  SuffixArray(string& s, int lim = 256) {
    int n = int(s.size()) + 1, k = 0, a, b;
    vector<int> x((s).begin(), (s).end() + 1), y(n), ws(max(n, lim)), rank(n);
    sa = lcp = y, iota((sa).begin(), (sa).end(), 0);
    for (int j = 0, p = 0; p < n; j = max(1, j * 2), lim = p) {
      p = j, iota((y).begin(), (y).end(), n - j);
      for (int i = (0); i < (n); ++i)
        if (sa[i] >= j) y[p++] = sa[i] - j;
      fill((ws).begin(), (ws).end(), 0);
      for (int i = (0); i < (n); ++i) ws[x[i]]++;
      for (int i = (1); i < (lim); ++i) ws[i] += ws[i - 1];
      for (int i = n; i--;) sa[--ws[x[y[i]]]] = y[i];
      swap(x, y), p = 1, x[sa[0]] = 0;
      for (int i = (1); i < (n); ++i)
        a = sa[i - 1], b = sa[i],
        x[b] = (y[a] == y[b] && y[a + j] == y[b + j]) ? p - 1 : p++;
    }
    for (int i = (1); i < (n); ++i) rank[sa[i]] = i;
    for (int i = 0, j; i < n - 1; lcp[rank[i++]] = k)
      for (k &&k--, j = sa[rank[i] - 1]; s[i + k] == s[j + k]; k++)
        ;
  }
};
string minsub(string t, int len) {
  SuffixArray sufarr(t);
  for (auto& st : sufarr.sa)
    if (st + len <= int(t.size())) {
      return t.substr(st, len);
    }
  return "?";
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (k == 1) {
    string t = s;
    reverse((t).begin(), (t).end());
    cout << minsub(s + t, n) << endl;
    return 0;
  }
  char lo = 'z';
  for (auto& c : s) lo = min(lo, c);
  if (k >= 20) {
    cout << string(n, lo) << endl;
    return 0;
  }
  int rek = 0;
  int tail = 0;
  for (int i = 0; i < int(s.size());) {
    if (s[i] != lo)
      ++i;
    else {
      int j = i + 1;
      while (j < int(s.size()) && s[j] == lo) ++j;
      if (j < int(s.size())) {
        rek = max(rek, j - i);
      } else {
        tail = j - i;
      }
      i = j;
    }
  }
  cerr << rek << ' ' << tail << endl;
  string ctail, cmin;
  if (tail == 0) {
    ctail = "";
  } else {
    long long len = long long(tail) << k;
    if (len >= n)
      ctail = string(n, lo);
    else {
      ctail = string(len, lo);
      for (int i = (n - tail); i-- > (len - tail);) ctail.push_back(s[i]);
    }
  }
  long long len = long long(rek) << (k - 1);
  if (len >= n)
    cmin = string(n, lo);
  else {
    cmin = string(len - rek, lo);
    string t = s;
    reverse((t).begin(), (t).end());
    cmin += minsub(s + t, n - int(cmin.size()));
  }
  string ans = ctail == "" ? cmin : cmin == "" ? ctail : min(cmin, ctail);
  cout << ans << endl;
}
