#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

string solve(string s, int k)
{
	int n=s.length();
	if(k==0) return s;
	string t=s;
	int ptr=n-1;
	while(ptr-1>=0&&s[ptr-1]==s[n-1]) ptr--;
	reverse(t.begin(),t.end());
	s+=t;
	s=s.substr(n-ptr,n);
	return solve(s,k-1);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	string s; cin>>s;
	char c='z';
	for(int i=0;i<n;i++) c=min(c,s[i]);
	if(k>=18)
	{
		for(int i=0;i<n;i++)
		{
			cout<<c;
		}
		cout<<'\n'; return 0;
	}
	string ans;
	for(int i=0;i<n;i++) ans+="z";
	string t=s;
	reverse(t.begin(),t.end());
	s+=t;
	for(int i=0;i<=n;i++)
	{
		string res = solve(s.substr(i,n),k-1);
		if(res<ans) ans=res;
	}
	cout<<ans<<'\n';
}
