S = list(input().split())
a = []

kazu = []
for i in range(1+10**6):
    kazu.append(str(i))


for i in range(len(S)):
    if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
        
print(a[0])
 S = list(input().split()) S list(input().split()) list input().split() ().split () input split a = [] a [] kazu = [] kazu [] for i in range(1+10**6):
    kazu.append(str(i)) i range(1+10**6) range 1+10**6 1 10**6 10 6 kazu.append(str(i)) kazu.append kazu append str(i) str i for i in range(len(S)):
    if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
         i range(len(S)) range len(S) len S if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
         S[i] in kazu S[i] S i kazu a.append(int(S[i])) a.append a append int(S[i]) int S[i] S i elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
     S[i] == "+" S[i] S i "+" x = a.pop() x a.pop() a.pop a pop y = a.pop() y a.pop() a.pop a pop a.append(x+y) a.append a append x+y x y elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

     S[i] == "-" S[i] S i "-" x = a.pop() x a.pop() a.pop a pop y = a.pop() y a.pop() a.pop a pop a.append(y-x) a.append a append y-x y x elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
         S[i] == "*" S[i] S i "*" x = a.pop() x a.pop() a.pop a pop y = a.pop() y a.pop() a.pop a pop a.append(x*y) a.append a append x*y x y print(a[0]) print a[0] a 0 y = a.pop() a.pop() y y = a.pop() a.pop() y x = a.pop() a.pop() x S = list(input().split()) list(input().split()) S x = a.pop() a.pop() x y = a.pop() a.pop() y kazu = [] [] kazu a = [] [] a x = a.pop() a.pop() x
S = list(input().split())
a = []

kazu = []
for i in range(1+10**6):
    kazu.append(str(i))


for i in range(len(S)):
    if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
        
print(a[0])

