#include <bits/stdc++.h>
using namespace std;
int main() {
  static int n, k;
  static string s;
  cin >> n >> k >> s;
  char c = 'z';
  for (int i = 0; i < s.size(); i++) {
    c = min(c, s[i]);
  }
  if (k >= 14) {
    string ret = "";
    for (int i = 0; i < n; i++) {
      ret += c;
    }
    cout << ret << endl;
    return 0;
  }
  int l = 0;
  vector<int> vec;
  string u = s;
  reverse(s.begin(), s.end());
  u += s;
  for (int i = 0; i < u.size(); i++) {
    int j = i;
    while (j < u.size() && u[j] == c) j++;
    if (l < j - i) {
      l = j - i;
      vec.clear();
      vec.push_back(i);
    } else if (l == j - i) {
      vec.push_back(i);
    }
  }
  int x = (1 << (k - 1)) * l;
  if (x >= n) {
    string ret = "";
    for (int i = 0; i < n; i++) {
      ret += c;
    }
    cout << ret << endl;
    return 0;
  }
  string ret = "";
  for (int i = 0; i < vec.size(); i++) {
    int id = vec[i];
    if (id < n - x) continue;
    string ret_ = "";
    for (int j = id - 1; j >= id - (n - x); j--) {
      ret_ += u[j];
    }
    if (ret == "")
      ret = ret_;
    else {
      for (int j = 0; j < n - x; j++) {
        if (ret[j] < ret_[j])
          break;
        else if (ret[j] > ret_[j]) {
          ret = ret_;
          break;
        }
      }
    }
  }
  for (int i = 0; i < x; i++) {
    printf("%c", c);
  }
  cout << ret << endl;
}
