a = [i for i in input().split()]
print(" ".join(i for i, n in zip(a, a[1::] + [1]) if n != '0'))