s = []
for t in input().split():
	try:
		v = int(t)
	except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	s.append(v)
print(s.pop()) s = [] s [] for t in input().split():
	try:
		v = int(t)
	except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	s.append(v) t input().split() ().split () input split try:
		v = int(t)
	except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	 except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	 a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	 t == '+' t '+' elif t == '-': v = b - a
		 t == '-' t '-' elif t == '*': v = b * a
	 t == '*' t '*' v = int(t) v int(t) int t s.append(v) s.append s append v print(s.pop()) print s.pop() s.pop s pop a = s.pop() s.pop() a s = [] [] s b = s.pop() s.pop() b v = int(t) int(t) v
s = []
for t in input().split():
	try:
		v = int(t)
	except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	s.append(v)
print(s.pop())
