#include <bits/stdc++.h>
using namespace std;
double START_TIME;
void exit() { exit(0); }
template <typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  for (int i = 0; i <= (int)v.size() - 1; i++) {
    os << v[i] << " ";
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> t) {
  for (auto z : t) {
    os << z << " ";
  }
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
  cerr << endl;
  for (auto z : t) {
    os << "\t" << z.first << " -> " << z.second << endl;
  }
  return os;
}
const int MAX = 5e3 + 41;
int n, k;
char s[MAX];
string ans;
void refresh(string& str) {
  if ((int)ans.size() == 0 || ans > str) ans = str;
}
string get(string s, int cnt) {
  int lq = 1;
  for (int i = (int)s.size() - 2; i >= 0; i--) {
    if (s[i] != s[i + 1]) break;
    lq++;
  }
  long long can = (lq << cnt);
  if (can >= n) {
    return string(n, s[n - 1]);
  }
  string res = "";
  int shift = can - lq;
  for (int i = shift; i <= n - 1; i++) {
    res.push_back(s[i]);
  }
  for (int i = 0; i <= can - 1 - lq; i++) {
    res.push_back(s[n - 1]);
  }
  assert((int)res.size() == n);
  reverse(res.begin(), res.end());
  return res;
}
void solve() {
  k = min(k, 30);
  string str = "";
  str += s;
  reverse(s, s + n);
  str += s;
  reverse(s, s + n);
  for (int i = 0; i <= n - 1; i++) {
    string cur = str.substr(i, n);
    string resp = get(cur, k - 1);
    refresh(resp);
  }
  printf("%s\n", ans.c_str());
}
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s);
  solve();
  exit();
  return 0;
}
