#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
const long long INFLL = (1ll << 60);
const long long MOD = (long long)(1e9 + 7);
void mul_mod(long long& a, long long b) {
  a *= b;
  a %= MOD;
}
void add_mod(long long& a, long long b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}
vector<string> v;
int main(void) {
  int n, i, k, p = 1, q;
  string s, t;
  cin >> n >> k;
  cin >> s;
  t = s;
  reverse(s.begin(), s.end());
  t += s;
  reverse(s.begin(), s.end());
  for (i = 0; i < n; ++i) {
    v.push_back(t.substr(i, n));
  }
  sort(v.begin(), v.end());
  if (v[0] != s) {
    --k;
  }
  while (p < n && v[0][p - 1] == v[0][p]) {
    ++p;
  }
  q = p;
  while (k) {
    q *= 2;
    if (q > n) {
      break;
    }
    --k;
  }
  q -= p;
  for (i = 0; i < min(q, n); ++i) {
    cout << v[0][0];
  }
  for (i = q; i < n; ++i) {
    cout << v[0][i - q];
  }
  cout << endl;
  return 0;
}
