#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	string s;
	cin >> s;
	for (int i = 0; i < num; i++)s.push_back(s[num - 1 - i]);
	char mini = 'z';
	for (int i = 0; i < s.size(); i++)mini = min(mini, s[i]);
	string ans;
	ans.push_back('z' + 1);
	if (kai == 1)
	{
		for (int i = 0; i <= num; i++)
		{
			string z;
			for (int j = 0; j < num; j++)z.push_back(s[i + j]);
			ans = min(ans, z);
		}
		cout << ans << endl;
		return 0;
	}
	for (int p = num; p <= num + num; p++)
	{
		int x = 0;
		for (int i = p - 1; i >= 0; i--)
		{
			if (s[i] == mini)x++;
			else break;
		}
		if (x == 0)continue;
		int xx = x;
		for (int i = 0; i < kai - 1; i++)
		{
			if (x == num)break;
			x = min(x * 2, num);
		}
		string z;
		for (int i = 0; i < x; i++)z.push_back(mini);
		for (int i = 0; i < num - x; i++)z.push_back(s[p - xx - i - 1]);
		ans = min(ans, z);
	}
	cout << ans << endl;
}