#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long md = 998244353LL) {
  long long res = 1;
  x %= md;
  while (y > 0) {
    if (y & 1) res = (res * x) % md;
    x = (x * x) % md;
    y = y >> 1;
  }
  return res % md;
}
long long min1() { return 1000000000000000000LL; }
long long max1() { return -1000000000000000000LL; }
template <typename... Args>
long long min1(long long a, Args... args) {
  return min(a, min1(args...));
}
template <typename... Args>
long long max1(long long a, Args... args) {
  return max(a, max1(args...));
}
struct node {
  std::vector<long long> v, w;
};
string ans;
char mn;
long long len;
string mmn;
long long ff = 0;
void dfs(string &second, long long c, long long k, long long mul) {
  if (ff) return;
  if (c == k) {
    if (ans > second) ans = second;
    return;
  }
  long long n = second.size();
  string t = second;
  reverse(t.begin(), t.end());
  string u = second + t;
  long long st = n - mul / 2;
  long long end = n - mul / 2;
  if (c == k - 1 || c == 0) {
    st = 0;
    end = n;
  }
  for (long long i = st; i <= end; i++) {
    string temp = u.substr(i, n);
    if (c == k - 1) {
      long long cnt = 0;
      for (long long i = 0; i < n; i++) {
        if (mn == temp[i])
          cnt++;
        else
          break;
      }
      if (cnt >= mul) dfs(temp, c + 1, k, mul * 2);
      continue;
    }
    long long cnt = 0;
    for (long long i = n - 1; i > -1; i--) {
      if (mn == temp[i])
        cnt++;
      else
        break;
    }
    long long pp = cnt;
    for (long long i = 0; i < k - 2 - c; i++) {
      pp *= 2;
    }
    if (pp >= n) {
      string temp = "";
      for (long long i = 0; i < n; i++) temp += mn;
      ans = mn;
      ff = 1;
      return;
    }
    if (cnt >= mul) dfs(temp, c + 1, k, mul * 2);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, k;
  cin >> n >> k;
  string second;
  cin >> second;
  mn = second[0];
  len = 1;
  long long cur = 1;
  for (long long i = 1; i < n; i++) {
    if (second[i] == second[i - 1]) {
      cur++;
    } else {
      if (second[i - 1] < mn) {
        mn = second[i - 1];
        len = cur;
      } else if (second[i - 1] == mn) {
        len = max(len, cur);
      }
      cur = 1;
    }
  }
  long long first = 0;
  if (second[n - 1] < mn) {
    mn = second[n - 1];
    len = cur;
  } else if (second[n - 1] == mn) {
    if (cur > len) {
      len = cur;
      first = 1;
    }
  }
  if (k + first > 14 || len == n) {
    for (long long i = 0; i < n; i++) cout << mn;
    return 0;
  } else {
    long long pp = len;
    for (long long i = 0; i < k - 1 + first; i++) {
      pp *= 2;
      if (pp >= n) {
        for (long long i = 0; i < n; i++) cout << mn;
        return 0;
      }
    }
  }
  mmn = second;
  ans = second;
  dfs(second, 0, k, len);
  cout << ans;
}
