#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s.resize(2 * s.size());
  for (int i = 0; i < n; i++) {
    s[2 * n - 1 - i] = s[i];
  }
  string mi, m;
  mi.resize(1e6);
  m.resize(1e6);
  for (int i = 0; i < 1e6; i++) {
    mi[i] = 'z';
    m[i] = 'z';
  }
  if (k == 1) {
    for (int i = 0; i <= n; i++) {
      mi = min(mi, s.substr(i, n));
    }
    cout << mi << endl;
  } else {
    reverse(s.begin(), s.end());
    for (int i = 0; i <= n; i++) {
      mi = min(mi, s.substr(i, n));
    }
    reverse(mi.begin(), mi.end());
    for (int i = k - 1; i >= max(2, i - 30); i--) {
      mi.resize(2 * n);
      for (int i = 0; i < n; i++) {
        mi[2 * n - 1 - i] = mi[i];
      }
      int pos;
      for (int j = n; j < 2 * n; j++) {
        if (mi[j] != mi[n]) break;
        pos = j;
      }
      pos++;
      mi = mi.substr(pos - n, n);
    }
    mi.resize(2 * n);
    for (int i = 0; i < n; i++) {
      mi[2 * n - 1 - i] = mi[i];
    }
    for (int i = 0; i <= n; i++) {
      m = min(m, mi.substr(i, n));
    }
    cout << m << endl;
  }
}
