#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int mi = INF, ma = -1, lo = 0;
  for (int i = 0; i < n; i++) {
    chmin(mi, s[i] - 'a');
  }
  char c = 'a' + mi;
  vector<pair<string, int>> vs;
  string rs = s;
  reverse(rs.begin(), rs.end());
  vs.push_back(make_pair(rs, n - 1));
  for (int i = 0; i < n - 1; i++) {
    string to = s.substr(i, n - i);
    to += rs.substr(0, i);
    vs.push_back(make_pair(to, i));
  }
  sort(vs.begin(), vs.end());
  for (int i = 0; i < n; i++) {
    if (vs[0].first[i] != c) {
      ma = i;
      break;
    }
  }
  if (ma == -1) {
    cout << s.substr(0, n) << endl;
    return 0;
  }
  for (int i = 0; i < k; i++) {
    string t = s;
    reverse(s.begin(), s.end());
    t += s;
    lo = 0;
    if (s[0] == c) {
      ma *= 2;
    } else {
      int id = vs[0].second;
      s = vs[0].first;
      if (i < k - 1) {
        reverse(s.begin(), s.end());
      }
      continue;
    }
    if (ma >= n) {
      for (int j = 0; j < n; j++) {
        cout << c;
      }
      cout << endl;
      return 0;
    }
    for (int j = t.length() - 1; j >= 0; j--) {
      if (t[j] == c) {
        lo++;
      } else {
        lo = 0;
      }
      if (lo == ma) {
        s = t.substr(j + ma - n, n);
      }
    }
    if (i == k - 1) {
      reverse(s.begin(), s.end());
    }
  }
  cout << s << endl;
}
