def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st


a=[]
stac=[]
a=list(input().split())
for i in range(len(a)):
	if a[i].isdigit():
		stac.append(int(a[i]))
		#print(stac)
	else:
		x=stac.pop()
		y=stac.pop()
		stac.append(kei(a,i,x,y))
		
print(stac[0])
		
 def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st kei if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	 a[i]=="+" a[i] a i "+" st=x+y st x+y x y elif a[i]=="-":
		st=y-x
		#print("-")
	 a[i]=="-" a[i] a i "-" st=y-x st y-x y x elif a[i]=="*":
		st=x*y
		#print("*") 
	 a[i]=="*" a[i] a i "*" st=x*y st x*y x y return st st a a i i x x y y a=[] a [] stac=[] stac [] a=list(input().split()) a list(input().split()) list input().split() ().split () input split for i in range(len(a)):
	if a[i].isdigit():
		stac.append(int(a[i]))
		#print(stac)
	else:
		x=stac.pop()
		y=stac.pop()
		stac.append(kei(a,i,x,y))
		 i range(len(a)) range len(a) len a if a[i].isdigit():
		stac.append(int(a[i]))
		#print(stac)
	else:
		x=stac.pop()
		y=stac.pop()
		stac.append(kei(a,i,x,y))
		 a[i].isdigit() [i].isdigit [i] a i isdigit stac.append(int(a[i])) stac.append stac append int(a[i]) int a[i] a i x=stac.pop() x stac.pop() stac.pop stac pop y=stac.pop() y stac.pop() stac.pop stac pop stac.append(kei(a,i,x,y)) stac.append stac append kei(a,i,x,y) kei a i x y print(stac[0]) print stac[0] stac 0 stac=[] [] stac def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st kei y=stac.pop() stac.pop() y a=[] [] a a=list(input().split()) list(input().split()) a x=stac.pop() stac.pop() x
def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st


a=[]
stac=[]
a=list(input().split())
for i in range(len(a)):
	if a[i].isdigit():
		stac.append(int(a[i]))
		#print(stac)
	else:
		x=stac.pop()
		y=stac.pop()
		stac.append(kei(a,i,x,y))
		
print(stac[0])
		

