<reponame>KaloyankerR/python-advanced-repository<gh_stars>0
from collections import deque

kids = deque(input().split())
toss = int(input())

while len(kids) > 1:
    kids.rotate(-(toss - 1))
    print(f"Removed {kids.popleft()}")

print(f"Last is {kids[0]}")
