#include <cstdio>
#include <iostream>
#include <algorithm>

int n, k, pos, len;
std::string s, t;
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> k >> s;
	if (k > 16 || (1 << k - 1) >= n) {
		std::cout << std::string(n, *std::min_element(s.begin(), s.end())) << '\n';
		return 0;
	}
	t = s, s = s + std::string(s.rbegin(), s.rend());
	for (int i = 0; i < n; ++i) t = std::min(t, s.substr(i, n));
	for (; pos <= n && t[pos] == t[0]; ++pos) ;
	len = std::min(n, pos << k - 1);
	std::cout << std::string(len, t[0]) << t.substr(pos, n - len) << '\n';
	return 0;
}
