#include <cmath>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=5005;
int n, k;
char s[N], t[N<<1];
int main() {
	assert(scanf("%d%d%s", &n, &k, s)==3);
	char c=*std::min_element(s, s+n);
	if(k>log2(n)+1) {
		std::fill(s, s+n, c);
		puts(s);
		return 0;
	}
	while(k--) {
		std::copy(s, s+n, t);
		std::reverse_copy(s, s+n, t+n);
		int cho=0;
		for(int i=1; i<=n; ++i) if(strcmp(t+i, t+cho)<0) cho=i;
		std::reverse_copy(t+cho, t+cho+n, s);
	}
	std::reverse(s, s+n);
	puts(s);
	return 0;
}
