N,K = map(int, input().split(' '))
S = input()
for i in range(N-K+1):
  S = S[:i] + S[i:i+K][::-1] + S[i+K:]
print(S)