package main

import (
	"fmt"
	"sort"
	"strings"
)

func reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var n int
	var k int
	fmt.Scan(&n)
	fmt.Scan(&k)
	var s string
	fmt.Scan(&s)
	chars := [26]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	var index int
	var count int
	var minChar string
	for i := 0; i < len(chars); i++ {
		a := strings.Index(s, chars[i])
		if a != -1 {
			minChar = chars[i]
			sep := chars[i]
			for true {
				b := strings.Index(s, (sep + chars[i]))
				if b == -1 {
					count++
					break
				}
				sep = sep + chars[i]
				count++
			}
			st := s + reverse(s)
			var sss []string
			b := strings.Index(s, sep)
			sss = append(sss, st[b:])
			for true {
				c := strings.Index(s[b+1:], sep)
				if c == -1 {
					break
				}
				b += c + 1
				sss = append(sss, st[b:])
			}
			sort.Strings(sss)
			index = strings.Index(st, sss[0])
			break
		}
	}
	for i := 0; i < k; i++ {
		if (index + count - 1) == n {
			count += count
		}
		if i == 0 {
			rs := reverse(s)
			s = s[(len(rs)-index):] + rs[:(len(rs)-index)]
		} else {
			for j := 0; j < count; j++ {
				s = s[1:] + minChar
			}
			count += count
		}
		if count >= n {
			break
		}
	}
	fmt.Println(reverse(s))
}
