stk = []
for c in input().split():
	if c in "+-*":
		a = stk.pop()
		b = stk.pop()
		stk.append(str(eval(b + c + a)))
	else:
		stk.append(c)
print(stk.pop())
 stk = [] stk [] for c in input().split():
	if c in "+-*":
		a = stk.pop()
		b = stk.pop()
		stk.append(str(eval(b + c + a)))
	else:
		stk.append(c) c input().split() ().split () input split if c in "+-*":
		a = stk.pop()
		b = stk.pop()
		stk.append(str(eval(b + c + a)))
	else:
		stk.append(c) c in "+-*" c "+-*" a = stk.pop() a stk.pop() stk.pop stk pop b = stk.pop() b stk.pop() stk.pop stk pop stk.append(str(eval(b + c + a))) stk.append stk append str(eval(b + c + a)) str eval(b + c + a) eval b + c + a b + c b c a stk.append(c) stk.append stk append c print(stk.pop()) print stk.pop() stk.pop stk pop a = stk.pop() stk.pop() a b = stk.pop() stk.pop() b stk = [] [] stk
stk = []
for c in input().split():
	if c in "+-*":
		a = stk.pop()
		b = stk.pop()
		stk.append(str(eval(b + c + a)))
	else:
		stk.append(c)
print(stk.pop())

