S = input() K = int(input()) for _ in range(K): S = S[0] + S S = S[:-1] print(S)