#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;
  int mn = 26, mx = 0, idx = 0;
  string t = s;
  reverse((t).begin(), (t).end());
  string ss;
  vector<string> sei;
  ss = s + t;
  for (long long i = 0; i < (long long)n + 1; i++) {
    mn = min(mn, ss[i] - 'a');
    string now;
    for (long long j = 0; j < (long long)n; j++) now += ss[i + j];
    sei.emplace_back(now);
  }
  sort((sei).begin(), (sei).end());
  if (k == 1) {
    cout << sei[0] << ENDL;
    return 0;
  }
  if (k > 20 || (n < (1ll << k))) {
    string ans;
    for (long long i = 0; i < (long long)n; i++) ans += (char)(mn + 'a');
    cout << ENDL;
    return 0;
  }
  s = sei[0];
  reverse((s).begin(), (s).end());
  for (long long i = 0; i < (long long)k - 2; i++) {
    vector<string> sei_now;
    t = s;
    reverse((t).begin(), (t).end());
    ss = s + t;
    for (long long i = 0; i < (long long)n + 1; i++) {
      string now;
      for (long long j = 0; j < (long long)n; j++) now += ss[i + j];
      sei_now.emplace_back(now);
    }
    sort((sei_now).begin(), (sei_now).end());
    s = sei_now[0];
    reverse((s).begin(), (s).end());
  }
  vector<string> sei_now;
  t = s;
  reverse((t).begin(), (t).end());
  ss = s + t;
  for (long long i = 0; i < (long long)n + 1; i++) {
    string now;
    for (long long j = 0; j < (long long)n; j++) now += ss[i + j];
    sei_now.emplace_back(now);
  }
  sort((sei_now).begin(), (sei_now).end());
  cout << sei_now[0] << ENDL;
}
