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