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