#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  string in;
  cin >> in;
  string s = in;
  reverse(in.begin(), in.end());
  s += in;
  vector<string> se;
  if (k == 1) {
    for (long long i = 0; i < n + 1; i++) {
      se.push_back(s.substr(i, n));
    }
    sort(se.begin(), se.end());
    cout << se[0] << endl;
    return 0;
  }
  k--;
  char c = 'z';
  for (long long i = 0; i < n * 2; i++)
    if (c > s[i]) c = s[i];
  long long ma = 0, now = 0;
  for (long long i = 0; i < n * 2; i++) {
    if (s[i] == c) {
      now++;
      ma = max(now, ma);
    } else
      now = 0;
  }
  ma = max(now, ma);
  long long sz = ma;
  for (long long i = 0; i < k; i++) {
    ma *= 2;
    if (ma >= n) {
      for (long long j = 0; j < n; j++) cout << c;
      cout << endl;
      return 0;
    }
  }
  long long l = n - ma;
  for (long long i = l; i < n * 2; i++) {
    bool ok = true;
    for (long long j = 0; j < sz; j++) {
      if (i + j >= n * 2 or s[i + j] != c) {
        ok = false;
        break;
      }
    }
    if (ok) {
      string t = s.substr(i - l, l);
      reverse(t.begin(), t.end());
      se.push_back(t);
    }
  }
  for (long long i = 0; i < ma; i++) cout << c;
  sort(se.begin(), se.end());
  cout << se[0] << endl;
}
