s = raw_input().split()

stack = []
for op in s:
	if op.isdigit():
		stack.append(op)
	else:
		b = int(stack.pop())
		a = int(stack.pop())
		ret = 0
		if op == "+":
			ret = a + b
		elif op == "-":
			ret = a - b
		elif op == "*":
			ret = a * b
		stack.append(str(ret))
print stack.pop() s = raw_input().split() s raw_input().split() ().split () raw_input split stack = [] stack [] for op in s:
	if op.isdigit():
		stack.append(op)
	else:
		b = int(stack.pop())
		a = int(stack.pop())
		ret = 0
		if op == "+":
			ret = a + b
		elif op == "-":
			ret = a - b
		elif op == "*":
			ret = a * b
		stack.append(str(ret)) op s if op.isdigit():
		stack.append(op)
	else:
		b = int(stack.pop())
		a = int(stack.pop())
		ret = 0
		if op == "+":
			ret = a + b
		elif op == "-":
			ret = a - b
		elif op == "*":
			ret = a * b
		stack.append(str(ret)) op.isdigit() op.isdigit op isdigit stack.append(op) stack.append stack append op b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop ret = 0 ret 0 if op == "+":
			ret = a + b
		elif op == "-":
			ret = a - b
		elif op == "*":
			ret = a * b
		 op == "+" op "+" ret = a + b ret a + b a b elif op == "-":
			ret = a - b
		 op == "-" op "-" ret = a - b ret a - b a b elif op == "*":
			ret = a * b
		 op == "*" op "*" ret = a * b ret a * b a b stack.append(str(ret)) stack.append stack append str(ret) str ret print stack.pop() stack.pop stack pop s = raw_input().split() raw_input().split() s b = int(stack.pop()) int(stack.pop()) b ret = a + b a + b ret stack = [] [] stack ret = a * b a * b ret a = int(stack.pop()) int(stack.pop()) a ret = a - b a - b ret ret = 0 0 ret
s = raw_input().split()

stack = []
for op in s:
	if op.isdigit():
		stack.append(op)
	else:
		b = int(stack.pop())
		a = int(stack.pop())
		ret = 0
		if op == "+":
			ret = a + b
		elif op == "-":
			ret = a - b
		elif op == "*":
			ret = a * b
		stack.append(str(ret))
print stack.pop()