#include <bits/stdc++.h>
using namespace std;
int n, k, t;
string str;
void read_input() {
  scanf("%d %d", &n, &k);
  cin >> str;
  t = (int)log2(n);
}
string answer = "";
void test(string temp) {
  int z = n - 1;
  while (z > 0 && temp[z - 1] == temp[n - 1]) z--;
  int curr = (1 << min(k - 1, t)) * (n - z);
  string fin = "";
  for (int i = 0; i < curr; i++) {
    fin += temp[n - 1];
  }
  int left = n - curr;
  for (int i = z - 1; left && i >= 0; i--, left--) {
    fin += temp[i];
  }
  if (answer == "")
    answer = fin;
  else
    answer = min(answer, fin);
}
void solve() {
  int biggest = 'z';
  for (int i = 0; i < n; i++) {
    biggest = min(biggest, str[i] - 'a');
  }
  if (k >= t) {
    for (int i = 0; i < n; i++) {
      answer += biggest + 'a';
    }
  } else {
    string d = str;
    reverse(d.begin(), d.end());
    str += d;
    int p = n * 2;
    for (int i = n - 1; i < p; i++) {
      if (str[i] - 'a' == biggest) {
        test(str.substr(i - n + 1, n));
      }
    }
  }
  cout << answer;
}
int main() {
  read_input();
  solve();
  return 0;
}
