#include <bits/stdc++.h>
using namespace std;
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0; i < ((int)(v).size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream& operator<<(ostream& o, const vector<T>& v) {
  if ((int)(v).size()) o << join(v);
  return o;
}
int N, K;
string S;
char dd(int i) { return (i < N) ? S[i] : S[N * 2 - 1 - i]; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  cin >> S;
  char mi = 'z';
  for (int i = 0; i < (N); ++i) mi = min(mi, S[i]);
  int l = 1;
  int con = 0;
  vector<int> rs;
  for (int i = 0; i < (N); ++i)
    if (S[i] == mi) {
      ++con;
      if (con == l)
        rs.push_back(i);
      else if (con > l) {
        con = l;
        rs.clear();
        rs.push_back(i);
      }
    } else
      con = 0;
  if (rs[rs.size() - 1] == N - 1) {
    int rest = 0;
    if (((N - 1) / l) >> K) {
      rest = N - (l << K);
    }
    for (int i = 0; i < (N - rest); ++i) cout << mi;
    for (int i = 0; i < (rest); ++i) cout << S[N - 1 - l - i];
    cout << "\n";
    return 0;
  }
  int rest = 0;
  if (((N - 1) / l) >> (K - 1)) {
    rest = N - (l << K);
  }
  for (int i = 0; i < (rest); ++i) {
    char mmi = 'z';
    for (auto it = rs.begin(); it != rs.end(); ++it) {
      mmi = min(mmi, dd((*it) + 1 + i));
    }
    for (auto it = rs.begin(); it != rs.end();) {
      if (dd((*it) + 1 + i) != mmi)
        it = rs.erase(it);
      else
        ++it;
    }
  }
  for (int i = 0; i < (N - rest); ++i) cout << mi;
  for (int i = 0; i < (rest); ++i) cout << dd(rs[0] + l + i);
  cout << "\n";
  return 0;
}
