#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1e18;
const long long mod = 1e9 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  k--;
  if (k == 0) {
    vector<long long> a(2 * n);
    for (long long i = 0; i < (2 * n); i++) {
      long long v = s[i] - 'a';
      a[i] = v;
    }
    vector<long long> dp(2 * n);
    for (long long i = 2 * n - 1; i >= 0; i--) {
      if (i == 2 * n - 1)
        dp[i] = 1;
      else {
        if (a[i] == a[i + 1]) {
          dp[i] = dp[i + 1] + 1;
        } else {
          dp[i] = 1;
        }
      }
    }
    vector<string> pre;
    long long num = INF;
    long long cnt = 0;
    for (long long i = 0; i < (2 * n); i++) {
      if (a[i] < num) {
        num = a[i];
        cnt = dp[i];
      }
      if (a[i] == num) {
        cnt = max(cnt, dp[i]);
      }
    }
    for (long long i = 0; i < (2 * n); i++) {
      if (a[i] == num && dp[i] == cnt) {
        if (i + n - 1 <= 2 * n - 1) {
          pre.push_back(s.substr(i, n));
        }
      }
    }
    sort(pre.begin(), pre.end());
    cout << pre[0] << endl;
    return 0;
  }
  vector<long long> a(2 * n);
  for (long long i = 0; i < (2 * n); i++) {
    long long v = s[i] - 'a';
    a[i] = v;
  }
  vector<long long> dp(2 * n);
  for (long long i = 0; i < (2 * n); i++) {
    if (i == 0)
      dp[i] = 1;
    else {
      if (a[i] == a[i - 1]) {
        dp[i] = dp[i - 1] + 1;
      } else {
        dp[i] = 1;
      }
    }
  }
  vector<string> pre;
  long long num = INF;
  long long cnt = 0;
  for (long long i = 0; i < (2 * n); i++) {
    if (a[i] < num) {
      num = a[i];
      cnt = dp[i];
    }
    if (a[i] == num) {
      cnt = max(cnt, dp[i]);
    }
  }
  for (long long i = 0; i < (2 * n); i++) {
    if (a[i] == num && dp[i] == cnt) {
      if (i >= n - 1) {
        pre.push_back(s.substr(i - n + 1, n));
      }
    }
  }
  vector<pair<string, long long>> x;
  long long m = pre.size();
  for (long long i = 0; i < (m); i++) {
    string y = pre[i].substr(0, n - cnt);
    reverse(y.begin(), y.end());
    x.push_back({y, i});
  }
  sort(x.begin(), x.end());
  string u = pre[x[0].second];
  long long val = 2;
  bool inf = false;
  for (long long i = 0; i < (k); i++) {
    val *= 2;
    if (val >= n) {
      inf = true;
      break;
    }
  }
  char c = 'a' + num;
  if (inf) {
    for (long long i = 0; i < (n); i++) {
      cout << c;
    }
    cout << endl;
  } else {
    string ans = "";
    for (long long i = 0; i < (n); i++) {
      if (i < n - val) {
        ans += u[i + val - 2];
      } else {
        ans += c;
      }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
  return 0;
}
