data = raw_input().split()
#figure = [chr(i) for i in range(ord('0'), ord('9')+1)]

stack = []

for i in range(len(data)):
	if data[i] == "+":
		stack[-2] = stack[-2] + stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	else:
		stack.append(int(data[i]))
		#print stack

print stack[0] data = raw_input().split() data raw_input().split() ().split () raw_input split stack = [] stack [] for i in range(len(data)):
	if data[i] == "+":
		stack[-2] = stack[-2] + stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	else:
		stack.append(int(data[i]))
		#print stack i range(len(data)) range len(data) len data if data[i] == "+":
		stack[-2] = stack[-2] + stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	else:
		stack.append(int(data[i]))
		#print stack data[i] == "+" data[i] data i "+" stack[-2] = stack[-2] + stack[-1] stack[-2] stack -2 stack[-2] + stack[-1] stack[-2] stack -2 stack[-1] stack -1 del stack[-1] stack[-1] stack -1 elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	 data[i] == "-" data[i] data i "-" stack[-2] = stack[-2] - stack[-1] stack[-2] stack -2 stack[-2] - stack[-1] stack[-2] stack -2 stack[-1] stack -1 del stack[-1] stack[-1] stack -1 elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	 data[i] == "*" data[i] data i "*" stack[-2] = stack[-2] * stack[-1] stack[-2] stack -2 stack[-2] * stack[-1] stack[-2] stack -2 stack[-1] stack -1 del stack[-1] stack[-1] stack -1 stack.append(int(data[i])) stack.append stack append int(data[i]) int data[i] data i print stack[0] stack 0 data = raw_input().split() raw_input().split() data stack = [] [] stack
data = raw_input().split()
#figure = [chr(i) for i in range(ord('0'), ord('9')+1)]

stack = []

for i in range(len(data)):
	if data[i] == "+":
		stack[-2] = stack[-2] + stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	else:
		stack.append(int(data[i]))
		#print stack

print stack[0]