import sys
def input():
    return sys.stdin.readline()[:-1]

n, k = map(int, input().split())
s = str(input())

u = s + s[::-1]
ss = s

times = min(n, k)
for i in range(times):
    for j in range(n):
        part = u[j:j+n]
        if part < ss:
            ss = part
    if s == ss:
        print(s)
        exit()
    s = ss
    u = s[::-1] + s

print(s)