#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const int N = 1e4 + 10;
int a[N];
string solve(string s, int k) {
  if (k == 0) return s;
  int n = s.size();
  string t = s;
  reverse(t.begin(), t.end());
  s = s + t;
  char z = 'z';
  for (int i = 0; i < s.size(); i++) z = min(z, s[i]);
  memset(a, 0, sizeof a);
  if (k > 20) {
    string y = "";
    for (int i = 0; i < n; i++) y += z;
    return y;
  }
  int ma = 0, id = 0;
  if (k != 1) {
    for (int i = 1; i <= s.size(); i++) {
      if (s[i - 1] == z) a[i] = 1 + a[i - 1];
      if (a[i] >= ma) {
        ma = a[i];
        id = i;
      }
    }
    string y = "";
    for (int i = id - n; i < id; i++) {
      y += s[i];
    }
    int p1 = 0;
    k--;
    while (ma < n && k > 1) {
      p1 = 1;
      for (int i = 0; i < ma; i++) y += z;
      ma *= 2;
      k--;
    }
    if (p1) {
      s = "";
      for (int i = y.size() - n; i < y.size(); i++) s += y[i];
      t = s;
      reverse(t.begin(), t.end());
      s = s + t;
      k = 1;
    }
  }
  ma = 0, id = 0;
  memset(a, 0, sizeof a);
  if (k == 1) {
    string y = "";
    for (int i = 2 * n; i; i--) {
      if (s[i - 1] == z) a[i] = a[i + 1] + 1;
      if (a[i] >= ma) {
        ma = a[i];
        id = i;
      }
    }
    for (int j = id - 1; j < id + n - 1; j++) y += s[j];
    return y;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  int k;
  int n;
  cin >> n >> k;
  cin >> s;
  vector<string> ans;
  string t = s;
  reverse(t.begin(), t.end());
  s = s + t;
  for (int i = 0; i < n; i++) {
    string y = "";
    for (int j = i; j < n + i; j++) y += s[j];
    ans.push_back(solve(y, k - 1));
  }
  sort(ans.begin(), ans.end());
  cout << ans[0] << '\n';
}
