s = raw_input()
sentence = s.split(" ")
stack = []

for factor in sentence:
	if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor))
print stack[0] s = raw_input() s raw_input() raw_input sentence = s.split(" ") sentence s.split(" ") s.split s split " " stack = [] stack [] for factor in sentence:
	if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor)) factor sentence if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor)) factor == "+" factor "+" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop c = a + b c a + b a b stack.append(c) stack.append stack append c elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	 factor == "-" factor "-" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop c = a - b c a - b a b stack.append(c) stack.append stack append c elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	 factor == "*" factor "*" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop c = a * b c a * b a b stack.append(c) stack.append stack append c stack.append(int(factor)) stack.append stack append int(factor) int factor print stack[0] stack 0 b = stack.pop() stack.pop() b c = a - b a - b c c = a + b a + b c b = stack.pop() stack.pop() b c = a * b a * b c b = stack.pop() stack.pop() b s = raw_input() raw_input() s stack = [] [] stack a = stack.pop() stack.pop() a a = stack.pop() stack.pop() a sentence = s.split(" ") s.split(" ") sentence a = stack.pop() stack.pop() a
s = raw_input()
sentence = s.split(" ")
stack = []

for factor in sentence:
	if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor))
print stack[0]