#include <bits/stdc++.h>

int n, k;
std::string s;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> k >> s;
	if (k > 16) {
		std::cout << std::string(n, *std::min_element(s.begin(), s.end())) << '\n';
	} else {
		std::string 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));
		int L = t.find_first_not_of(t[0]), R = std::min(L << k - 1, n);
		std::cout << std::string(R, t[0]) << t.substr(L, n - R) << '\n';
	}
	return 0;
}