import sys
def solve():
"""
Solves a single test case using dynamic programming.
"""
try:
n, k = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().strip()
except (IOError, ValueError):
return
# dp[i] will store the best possible suffix string starting from index i
dp = [''] * (n + 1)
# Iterate from the end of the string to the beginning
for i in range(n - 1, -1, -1):
# Option 1: Don't start a rearrangement at i.
option1 = s[i] + dp[i + 1]
# Option 2: Start a rearrangement, if possible.
if i + k <= n:
substring_to_sort = s[i : i + k]
sorted_block = "".join(sorted(substring_to_sort))
option2 = sorted_block + dp[i + k]
# Choose the lexicographically smaller result
if option1 < option2:
dp[i] = option1
else:
dp[i] = option2
else:
# If a block of size k cannot be formed, we have no other choice.
dp[i] = option1
print(dp[0])
# Since there is only one test case according to the problem description
solve()