N,K=map(int,input().split())
S=input()
C=min(S)
T=0
L=0
U=S
c=0
P='z'*N
for l in range(-1,1):
  for i in range(K-1):
    T=S
    T=T+S[::-1]
    L=[T[j:j+N] for j in range(N+1)]
    L.sort(key=lambda x:x[::-1])
    c=0
    for j in range(N):
      if L[0][-j-1]!=C:
        break
      c+=1
    while max(L[-1][-c:])!=C:
      del L[-1]
    S=L[l]
    if max(S)==C:
      break
  T=S
  T=T+S[::-1]
  L=[T[j:j+N] for j in range(N+1)]
  L.sort()
  P=min(P,L[0])
  S=U
print(P)