#include <bits/stdc++.h>
using namespace std;
string ans;
void dfs(int lft, string res) {
  if (!lft) {
    if (ans == "")
      ans = res;
    else
      ans = min(ans, res);
    return;
  }
  string t = res;
  reverse(t.begin(), t.end());
  t = res + t;
  for (int i = 0; i <= res.size(); i++) dfs(lft - 1, t.substr(i, res.size()));
}
int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  while (k--) {
    string t = s;
    reverse(t.begin(), t.end());
    t = s + t;
    string s2 = s;
    if (k == 0) {
      for (int i = 1; i <= s.length(); i++)
        s2 = min(s2, t.substr(i, s.length()));
      cout << s2;
      return 0;
    }
    reverse(t.begin(), t.end());
    reverse(s2.begin(), s2.end());
    for (int i = 1; i <= s.length(); i++) s2 = min(s2, t.substr(i, s.length()));
    reverse(s2.begin(), s2.end());
    bool same = 1;
    for (int i = 1; i < s.length(); i++)
      if (s[i] != s[i - 1]) same = 0;
    if (same) {
      cout << s2;
      return 0;
    }
    s = s2;
  }
  return 0;
}
