f = raw_input().split(" ")
stack = []
for i in f:
	if i.isdigit():
		stack.append(int(i))
	else:
		y = stack.pop()
		x = stack.pop()
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y)
print stack.pop() f = raw_input().split(" ") f raw_input().split(" ") ().split () raw_input split " " stack = [] stack [] for i in f:
	if i.isdigit():
		stack.append(int(i))
	else:
		y = stack.pop()
		x = stack.pop()
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y) i f if i.isdigit():
		stack.append(int(i))
	else:
		y = stack.pop()
		x = stack.pop()
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y) i.isdigit() i.isdigit i isdigit stack.append(int(i)) stack.append stack append int(i) int i y = stack.pop() y stack.pop() stack.pop stack pop x = stack.pop() x stack.pop() stack.pop stack pop if i == "+":
			stack.append(x+y)
		 i == "+" i "+" stack.append(x+y) stack.append stack append x+y x y if i == "-":
			stack.append(x-y)
		 i == "-" i "-" stack.append(x-y) stack.append stack append x-y x y if i == "*":
			stack.append(x*y) i == "*" i "*" stack.append(x*y) stack.append stack append x*y x y print stack.pop() stack.pop stack pop f = raw_input().split(" ") raw_input().split(" ") f y = stack.pop() stack.pop() y stack = [] [] stack x = stack.pop() stack.pop() x
f = raw_input().split(" ")
stack = []
for i in f:
	if i.isdigit():
		stack.append(int(i))
	else:
		y = stack.pop()
		x = stack.pop()
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y)
print stack.pop()