n,k=map(int,input().split()) s=input() r=n-k+1 for i in range(r): nw=''.join(list(reversed(s[i:i+k]))) if i<1: s=nw+s[i+k:] else: s=s[:i]+nw+s[i+k:] print(s)