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