#python2.7

A=raw_input().split()
B=[]
for i in A:
	if i.isdigit():
		B.append(i)
	else:
		if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2]
print B[0] A=raw_input().split() A raw_input().split() ().split () raw_input split B=[] B [] for i in A:
	if i.isdigit():
		B.append(i)
	else:
		if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2] i A if i.isdigit():
		B.append(i)
	else:
		if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2] i.isdigit() i.isdigit i isdigit B.append(i) B.append B append i if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2] i=="+" i "+" B[-1]=str(int(B[-1])+int(B[-2])) B[-1] B -1 str(int(B[-1])+int(B[-2])) str int(B[-1])+int(B[-2]) int(B[-1]) int B[-1] B -1 int(B[-2]) int B[-2] B -2 del B[-2] B[-2] B -2 elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		 i=="-" i "-" B[-1]=str(int(B[-2])-int(B[-1])) B[-1] B -1 str(int(B[-2])-int(B[-1])) str int(B[-2])-int(B[-1]) int(B[-2]) int B[-2] B -2 int(B[-1]) int B[-1] B -1 del B[-2] B[-2] B -2 elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2] i=="*" i "*" B[-1]=str(int(B[-1])*int(B[-2])) B[-1] B -1 str(int(B[-1])*int(B[-2])) str int(B[-1])*int(B[-2]) int(B[-1]) int B[-1] B -1 int(B[-2]) int B[-2] B -2 del B[-2] B[-2] B -2 print B[0] B 0 B=[] [] B A=raw_input().split() raw_input().split() A
#python2.7

A=raw_input().split()
B=[]
for i in A:
	if i.isdigit():
		B.append(i)
	else:
		if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2]
print B[0]