#include <bits/stdc++.h>
using namespace std;
long long x, y, n, m, k;
long long a[105][105], d[105][105];
int main() {
  cin >> n >> k;
  string s;
  cin >> s;
  string ans = s;
  char c = 'z';
  for (int i = 0; i < n; i++) {
    c = min(c, s[i]);
  }
  if (k >= 13) {
    for (int i = 0; i < n; i++) {
      cout << c;
    }
    cout << endl;
    return 0;
  }
  string t = s;
  reverse(t.begin(), t.end());
  s.append(t);
  k--;
  if (k == 0) {
    for (int i = 0; i <= n; i++) {
      string x;
      for (int j = 0; j < n; j++) {
        x.push_back(s[i + j]);
      }
      if (x < ans) {
        ans = x;
      }
    }
    cout << ans << endl;
    return 0;
  } else {
    long long cnt = 0, cur = 0;
    for (int i = 0; i < 2 * n; i++) {
      if (s[i] == c) {
        cur++;
      } else {
        cnt = max(cnt, cur);
        cur = 0;
      }
    }
    cnt = max(cnt, cur);
    long long lf = (cnt << k);
    if ((cnt << k) >= n) {
      for (int i = 0; i < n; i++) {
        cout << c;
      }
      cout << endl;
      return 0;
    }
    cur = 0;
    string ending = "";
    for (int i = 0; i < 2 * n; i++) {
      if (i + (n - lf) >= 2 * n) {
        break;
      }
      if (s[i] == c) {
        cur++;
      } else {
        cur = 0;
      }
      if (cur == cnt) {
        string tmp;
        for (int j = i + 1; j <= i + (n - lf); j++) {
          tmp.push_back(s[j]);
        }
        if (ending == "") {
          ending = tmp;
        } else if (tmp < ending) {
          ending = tmp;
        }
      }
    }
    for (int i = 0; i < lf; i++) {
      cout << c;
    }
    cout << ending << endl;
  }
  return 0;
}
