n,k=map(int,input().split())
s=input()
slist=list(s)
num=0
for i in range(17):
    if 2**num>=n:
        num+=1
        break
    num+=1
if k>=num:
    slist.sort()
    ans=slist[0]*n
    print(ans)
else:
    for i in range(n):
        slist.append(slist[n-1-i])
    s1=[]
    for i in range(n+1):
        s1.append(slist[i:i+n])
    s1.sort()
    sstr=s1[0]
    ss2=""
    for i in range(n):
        ss2+=sstr[i]
    s3=sstr[0]
    num10=1
    for i in range(n-1):
        if s3!=sstr[i+1]:
            break
        else:
            num10+=1
    s2=""
    for i in range(n):
        s2+=sstr[-1-i]
    slist.sort()
    num=min((2**(k-1))*num10,n)
    num2=n-num
    ans=slist[0]*num
    ans+=ss2[num10:num10+num2]
    print(ans)
