import binascii
n, k = [int(x) for x in input().split()]
s = input()

candidates = [s]
visited = set()
ret = ""


def get_smaller(target, current):
    if current == "":
        return target
    else:
        current_hex = binascii.hexlify(current.encode('utf-8', 'replace'))
        current_hex = int(current_hex, 16)
        target_hex = binascii.hexlify(target.encode('utf-8', 'replace'))
        target_hex = int(target_hex, 16)
        if target_hex < current_hex:
            return target
        else:
            return current


minimum_char = 'z'
for item in s:
    minimum_char = get_smaller(item, minimum_char)

flg = False
for _ in range(k):
    tmp_candidates = []
    for _ in range(len(candidates)):
        cand = candidates.pop(0)
        ret = get_smaller(cand, ret)
        candr = cand[::-1]
        new_s = cand + candr

        cnt = 0
        for i in range(1, len(new_s) - n + 1):
            new_cand = new_s[i:i+n]
            if new_cand in visited:
                cnt += 1
            else:
                visited.add(new_cand)
                tmp_candidates.append(new_cand)
                ret = get_smaller(new_cand, ret)
        if cnt == len(new_s) - n or ret == minimum_char * n:
            flg = True
        if flg:
            break
    if flg:
        break
    else:
        renewal_candidates = []
        max_len = 0
        for item in tmp_candidates:
            tmp_len = 0
            for i in range(n-1, -1, -1):
                if item[i] == minimum_char:
                    tmp_len += 1
                else:
                    break
            if tmp_len > max_len:
                max_len = tmp_len
                if len(renewal_candidates) != 0:
                    renewal_candidates = [item]
                else:
                    renewal_candidates.append(item)
            elif tmp_len == max_len:
                if len(renewal_candidates) == 0:
                    renewal_candidates = [item]
                else:
                    renewal_candidates.append(item)

        if len(renewal_candidates) != 0:
            candidates.extend(renewal_candidates)
        else:
            candidates.extend(tmp_candidates)

print(ret)
