def main():
    n, k = map(int, input().split())
    s = list(input())
    for i in range(n - k + 1):
        s = s[:i] + s[i:i + k][::-1] + s[i + k:]
    print(''.join(s))

if __name__ == '__main__':
    main()