n,k=map(int,input().split())
s=list(input())
import sys
input=sys.stdin.readline
s.reverse()
if k>=n:
    print(min(s)*n)
else:
    for i in range(min(k,n)):
        t=list(reversed(s))
        u=t+s
        uu=u[:n]
        for j in range(1,n+1):
            x=u[j:j+n]
            if uu>x:
                uu=x
        s=uu
    print("".join(s))
