#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, k, m, i, j, mn = 1000;
string s, t, u, ans;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie();
  cin >> n >> k;
  cin >> s;
  u = s;
  reverse(u.begin(), u.end());
  t = s + u;
  for (i = 0; i < n; i++) {
    if (s[i] < mn) mn = s[i];
    ans += 'z';
  }
  for (i = 0; i < n; i++) {
    string s1 = "", res = "";
    for (j = i; j < i + n; j++) s1 += t[j];
    if (k == 1) {
      ans = min(ans, s1);
      continue;
    }
    if (s1[s1.size() - 1] != mn) continue;
    int r = 0, cr, cl = 0;
    while (n - 1 - r >= 0 && s1[n - 1 - r] == mn) r++;
    cr = n - r;
    cl = 0;
    for (j = 0; r != 2 * n && j < k - 2; j++) cl += r, r = min(r * 2, 2 * n);
    for (j = cl; j < cr; j++) res += s1[j];
    while (res.size() != n + (n - max(0, cr - cl))) res += char(mn);
    reverse(res.begin(), res.end());
    res.resize(n);
    ans = min(ans, res);
  }
  cout << ans;
  return 0;
}
