#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += 998244353;
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 998244353) a -= 998244353;
}
template <typename T>
inline T const &MAX(T const &a, T const &b) {
  return a > b ? a : b;
}
template <typename T>
inline T const &MIN(T const &a, T const &b) {
  return a < b ? a : b;
}
inline long long mul(long long a, long long b, long long c) {
  return (a * b - (long long)((long double)a * b / c) * c + c) % c;
}
inline long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 998244353;
    a = a * a % 998244353, b >>= 1;
  }
  return ans;
}
inline long long qp(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a, c);
    a = mul(a, a, c), b >>= 1;
  }
  return ans;
}
using namespace std;
const long double pi = acos(-1);
const unsigned long long ba = 233;
const double eps = 1e-5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 100 + 10, maxn = 2000000 + 10, inf = 0x3f3f3f3f;
string s;
char mi = 'z';
string gao(string s, int k) {
  if (!k) return s;
  int n = s.size();
  while (k--) {
    int num = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == mi)
        num++;
      else
        break;
    }
    if (num == n) return s;
    string t = s;
    reverse(t.begin(), t.end());
    if (k == 0) return (s + t).substr(n - num, n);
    s = (s + t).substr(num, n);
  }
  return s;
}
int main() {
  int n, k;
  cin >> n >> k >> s;
  for (int i = 0; i < s.size(); i++) mi = min(mi, s[i]);
  string ans = s;
  for (int i = 0; i < s.size() - 1; i++)
    if (s[i] == mi) {
      string t = s;
      reverse(t.begin(), t.end());
      t = (s + t).substr(s.size() - i, s.size());
      ans = min(ans, gao(t, k - 1));
    }
  if (s[s.size() - 1] == mi) ans = min(ans, gao(s, k));
  cout << ans;
  return 0;
}
