# a=input()
# b=''
# for i in range(len(a)-1,-1,-1):
# b=b+a[i]
# print(b)
a=input().split()
list=[]
b=0
for i in range(len(a)):
if a[i] == "*":
x = list.pop()
y = list.pop()
list.append(x*y)
elif a[i] == "+":
x = list.pop()
y = list.pop()
list.append(x+y)
elif a[i] == "-":
x = list.pop()
y = list.pop()
list.append(y-x)
elif a[i] == " ":
pass
else:
list.append(int(a[i]))
while len(list)!=0 :
b=b+list.pop()
print(b)