#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
inline bool upmax(T1& a, T2 b) {
  return (a < b ? (a = b, true) : false);
}
template <typename T1, typename T2>
inline bool upmin(T1& a, T2 b) {
  return (b < a ? (a = b, true) : false);
}
const int maxn = (int)3e5 + 100;
const int maxlog = 21;
const int base = 1e9 + 7;
const long double eps = (long double)1e-9;
const long double PI = acos(-1.);
const int inf = 2e9;
const long long llinf = 1e18;
string zhad(string s) {
  string t = s;
  reverse((t).begin(), (t).end());
  string u = s + t;
  string opt = s;
  for (int i = 0; i + s.size() <= u.size(); i++) {
    string cur;
    for (int j = 0; j < s.size(); j++) cur += u[i + j];
    if (cur < opt) opt = cur;
  }
  return opt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < k; i++) {
    string nxt = zhad(s);
    if (s == nxt) break;
    s = nxt;
  }
  cout << s;
  return 0;
}
