#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
long long n, k;
string s;
bool cmp(long long a, long long b) {
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    if (s[a - i - 1] != s[b - i - 1]) {
      return s[a - i - 1] < s[b - i - 1];
    }
  }
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> k >> s;
  k--;
  mini(k, 20ll);
  string s2 = s;
  reverse((s2).begin(), (s2).end());
  s += s2;
  long long naj = n;
  for (long long i = n; i < 2 * n; i++) {
    if (cmp(i, naj)) {
      naj = i;
    }
  }
  long long same = 0;
  while (s[naj - same - 1] == s[naj - 1]) {
    same++;
  }
  for (long long i = (0); i <= ((long long)(min(n, same * (1 << k))) - 1);
       i++) {
    cout << s[naj - 1];
  }
  for (long long i = (0); i <= ((long long)(n - min(n, same * (1 << k))) - 1);
       i++) {
    cout << s[naj - same - i - 1];
  }
  cout << "\n";
}
