#coding:UTF-8
def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
  
if __name__=="__main__":
    a=input()
    A=a.split(" ")
    Stack(A) def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
   Stack p=[] p [] symbol=["+","-","*"] symbol ["+","-","*"] "+" "-" "*" for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
     i range(len(A)) range len(A) len A if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
     A[i] in symbol A[i] A i symbol if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
         A[i]=="+" A[i] A i "+" p.append(p.pop()+p.pop()) p.append p append p.pop()+p.pop() p.pop() p.pop p pop p.pop() p.pop p pop elif A[i]=="-":
                p.append(-p.pop()+p.pop())
             A[i]=="-" A[i] A i "-" p.append(-p.pop()+p.pop()) p.append p append -p.pop()+p.pop() -p.pop() p.pop() p.pop p pop p.pop() p.pop p pop p.append(p.pop()*p.pop()) p.append p append p.pop()*p.pop() p.pop() p.pop p pop p.pop() p.pop p pop p.append(int(A[i])) p.append p append int(A[i]) int A[i] A i print(p[0]) print p[0] p 0 A A if __name__=="__main__":
    a=input()
    A=a.split(" ")
    Stack(A) __name__=="__main__" __name__ "__main__" a=input() a input() input A=a.split(" ") A a.split(" ") a.split a split " " Stack(A) Stack A A=a.split(" ") a.split(" ") A a=input() input() a def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
   def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
   Stack
#coding:UTF-8
def Stack(A):
    p=[]
    symbol=["+","-","*"]
    for i in range(len(A)):
        if A[i] in symbol:
            if A[i]=="+":
                p.append(p.pop()+p.pop())
            elif A[i]=="-":
                p.append(-p.pop()+p.pop())
            else:
                p.append(p.pop()*p.pop())
        else:
            p.append(int(A[i]))
    
    print(p[0])
  
if __name__=="__main__":
    a=input()
    A=a.split(" ")
    Stack(A)