n,k = (int(x) for x in input().split())
s = str(input())
slist = sorted(list(s))
if len(slist)-1<k:
  ans = ""
  for t in slist:
    ans += slist[0]
  print(ans)
else:
  ss = s + s[::-1]
  #print(ss)
  lens = len(s)
  rev = []
  for i in range(k-1):
    for x in range(lens+1):
      r = ss[x:lens+x]
      rev.append(r[::-1])
    sortrev = sorted(rev)
    tmp = sortrev[0]
    ss = tmp[::-1]+tmp
    #print(tmp[::-1])
    #print(ss)
    rev = []
  for x in range(lens+1):
    r = ss[x:lens+x]
    rev.append(r)
  sortrev = sorted(rev)
  print(sortrev[0])


