import sys
arr = list(map(int, sys.stdin.readline().split()))
for i in range(len(arr)):
    if arr[i] != arr[len(arr) - 1] and arr[i + 1] == 0:
        continue
    else:
        print(arr[i], end=' ')