#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
void precalc() {}
const int maxn = 5005;
char tmp[maxn];
int n, k;
string s;
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  scanf("%s", tmp);
  s = tmp;
  return true;
}
string ans;
string best;
char mn;
void check(string s, int k) {
  while (k) {
    if (s == best) {
      return;
    }
    int x = 0;
    while (x < n && s[n - 1 - x] == mn) {
      x++;
    }
    s = s.substr(x, n - x) + string(x, mn);
    k--;
  }
  reverse(s.begin(), s.end());
  ans = min(ans, s);
}
void solve() {
  ans = s;
  mn = s[0];
  for (int i = 1; i < n; i++) {
    mn = min(mn, s[i]);
  }
  best = string(n, mn);
  if (ans == best) {
    printf("%s\n", ans.c_str());
    return;
  }
  string t = s;
  reverse(t.begin(), t.end());
  string u = s + t;
  if (k == 1) {
    for (int i = 0; i <= n; i++) {
      ans = min(ans, u.substr(i, n));
    }
    printf("%s\n", ans.c_str());
    return;
  }
  for (int i = 0; i <= n; i++) {
    if (u[i + n - 1] != mn) {
      continue;
    }
    check(u.substr(i, n), (i == 0 ? k : k - 1));
    if (ans == best) {
      break;
    }
  }
  printf("%s\n", ans.c_str());
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}
