#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
constexpr long long INF = 1000000000000000000;
constexpr long long mod = 998244353;
long long dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool prime(long long a) {
  if (a == 1) return false;
  for (long long i = 2; i * i <= a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}
vector<long long> kaijo;
void init_fact(long long n) {
  kaijo.resize(n + 1);
  kaijo[0] = 1;
  for (long long i = 1; i <= n; i++) {
    kaijo[i] = kaijo[i - 1] * i;
    kaijo[i] %= mod;
  }
}
long long modpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return modpow(a, b - 1) * a % mod;
  long long memo = modpow(a, b / 2);
  return memo * memo % mod;
}
long long comb(long long a, long long b) {
  return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod *
         modpow(kaijo[b], mod - 2) % mod;
}
long long inv(long long x) {
  x = modpow(x, mod - 2);
  return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy,
          double dx, double dy) {
  double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
  return tc * td < 0 && ta * tb < 0;
}
long long n, k;
string s;
signed main() {
  cin >> n >> k >> s;
  if (k >= 20) {
    char mi = 'z';
    for (char c : s) chmin(mi, c);
    for (long long i = 0; i < n; i++) cout << mi;
    cout << endl;
    return 0;
  }
  string t = s;
  reverse(t.begin(), t.end());
  t = s + t;
  if (k == 1) {
    string ans;
    for (long long i = 0; i < n; i++) {
      string u = t.substr(i, n);
      if (i == 0)
        ans = u;
      else
        chmin(ans, u);
    }
    cout << ans << endl;
    return 0;
  }
  k--;
  string ans;
  for (long long i = 0; i < n; i++) {
    string u = t.substr(i, n);
    reverse(u.begin(), u.end());
    for (long long _ = 0; _ < k; _++) {
      long long len = 0;
      for (long long j = 0; j < n; j++) {
        if (j) {
          if (u[j] == u[j - 1])
            ;
          else {
            len = j;
            break;
          }
        }
      }
      u = u.substr(0, len) + u.substr(0, n - len);
    }
    if (i == 0)
      ans = u;
    else
      chmin(ans, u);
  }
  cout << ans << endl;
  return 0;
}
