n = input().split() k = [] for i in range(len(n)): if int(n[i]) == 0 and i != 0: k.append(n[i]) i -= 1 k.remove(n[i]) else: k.append(n[i]) print(*k)