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