s = input()
stack = []#栈实现中序输出 ps:若是队列,则是中序
ans = []
for x in s:
    if x != "#":
        stack.append(x)
    else:
        if stack:
            ans.append(stack.pop())
h = " ".join(ans) + " "
print(h)