#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int infi = 1147483600;
const long long infl = 1e18 + 5;
const char ENDL = '\n';
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (k == 1) {
    string t = s;
    reverse((t).begin(), (t).end());
    string ss = s + t;
    vector<string> res;
    for (long long i = 0; i < (long long)n + 1; i++) {
      string r;
      for (long long j = 0; j < (long long)n; j++) {
        r += ss[i + j];
      }
      res.emplace_back(r);
    }
    sort((res).begin(), (res).end());
    cout << res[0] << ENDL;
    return 0;
  }
  int mn = 26, mx = 0, cnt = 0, idx = -1;
  mn = s[0] - '0';
  idx = 0;
  cnt = 1;
  for (long long i = (long long)1; i < (long long)n; i++) {
    if (s[i - 1] == s[i])
      cnt++;
    else {
      if (mn > s[i - 1] - '0') {
        mn = s[i - 1] - '0';
        mx = cnt;
        cnt = 1;
        idx = i - mx;
      } else if (mn == s[i - 1] - '0' && mx < cnt) {
        mx = cnt;
        cnt = 1;
        idx = i - mx;
      } else {
        cnt = 1;
      }
    }
  }
  bool flag = true;
  if (mn > s[n - 1] - '0') {
    mn = s[n - 1] - '0';
    mx = cnt;
    idx = n - mx;
  } else if (mn == s[n - 1] - '0' && mx <= cnt) {
    mx = cnt;
    idx = n - mx;
  } else
    flag = false;
  if (k > 13 || n < (1ll << k)) {
    string t;
    for (long long i = 0; i < (long long)n; i++) t += (char)(mn + 'a');
    cout << t << ENDL;
    return 0;
  }
  if (!(flag)) {
    string t = s;
    reverse((t).begin(), (t).end());
    string ss = s + t;
    s = "";
    for (long long i = (long long)n - idx; i < (long long)2 * n - idx; i++)
      s += ss[i];
    k--;
    idx = n - mx;
  }
  for (long long x = 0; x < (long long)k - 1; x++) {
    string t = s;
    reverse((t).begin(), (t).end());
    string ss = s + t;
    s = "";
    for (long long i = (long long)n - idx; i < (long long)2 * n - idx; i++)
      s += ss[i];
    idx = n;
    while (s[idx - 1] - 'a' == mn) {
      idx--;
      if (idx == 0) {
        cout << s << ENDL;
        return 0;
      }
    }
  }
  string t = s;
  reverse((t).begin(), (t).end());
  string ss = s + t;
  string ans;
  for (long long i = (long long)idx; i < (long long)idx + n; i++) ans += ss[i];
  cout << ans << ENDL;
}
