#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c = *min_element(s.begin(), s.end());
  if (k >= 14) {
    string ans;
    for (int i = 0; i < n; i++) ans += c;
    cout << ans << endl;
    return 0;
  }
  vector<string> v;
  for (int i = 0; i < n;) {
    if (s[i] != c) {
      i++;
      continue;
    }
    string t;
    int r = i;
    for (; r < n; r++) {
      if (s[r] != c) break;
    }
    if ((1 << (k - 1)) * (r - i) >= n) {
      string ans;
      for (int j = 0; j < n; j++) ans += c;
      cout << ans << endl;
      return 0;
    }
    int l = (1 << (k - 1)) * (r - i);
    for (int j = 0; j < l; j++) t += c;
    bool nuo = 0;
    int p = r;
    for (int j = 0; j < n - l; j++) {
      if (p == n) {
        nuo = 1;
        p--;
      }
      t += s[p];
      if (nuo)
        p--;
      else
        p++;
    }
    v.push_back(t);
    i = r;
  }
  cout << *min_element(v.begin(), v.end()) << endl;
  return 0;
}
