import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int,readline().split())
S = read().rstrip().decode('utf-8')

if K > 30:
    K = 30

SS = S + S[::-1]

if K == 1:
    answer = min(SS[i:i+N] for i in range(N+1))
    print(answer)
    exit()

min_ch = min(S)
run_len = [0] * len(SS)
for i,x in enumerate(SS):
    if x == min_ch:
        run_len[i] = run_len[i-1] + 1

max_len = max(run_len)
I = [i for i,x in enumerate(run_len[N-1:],N-1) if x == max_len]

if (max_len << (K-1)) >= N:
    answer = min_ch * N
    print(answer)
    exit()

L = max_len << (K-1)
cand = []
for i in I:
    T = SS[i-N+1:i+1]
    cand.append(T[-max_len-1:-max_len-(N-L)-1:-1])

answer = min_ch * L + min(cand)
print(answer)