exp  = input().split()
stk = []

for i in exp :
    if i in ('+', '-', '*') :
        num1 = stk.pop()
        num2 = stk.pop()
        
        if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
    else :
        stk.append(i)
        
print(stk.pop()) exp  = input().split() exp input().split() ().split () input split stk = [] stk [] for i in exp :
    if i in ('+', '-', '*') :
        num1 = stk.pop()
        num2 = stk.pop()
        
        if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
    else :
        stk.append(i)
         i exp if i in ('+', '-', '*') :
        num1 = stk.pop()
        num2 = stk.pop()
        
        if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
    else :
        stk.append(i)
         i in ('+', '-', '*') i ('+', '-', '*') '+' '-' '*' num1 = stk.pop() num1 stk.pop() stk.pop stk pop num2 = stk.pop() num2 stk.pop() stk.pop stk pop if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
     i == '+' i '+' stk.append(str(int(num1) + int(num2))) stk.append stk append str(int(num1) + int(num2)) str int(num1) + int(num2) int(num1) int num1 int(num2) int num2 elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
         i == '-' i '-' stk.append(str(int(num2) - int(num1))) stk.append stk append str(int(num2) - int(num1)) str int(num2) - int(num1) int(num2) int num2 int(num1) int num1 stk.append(str(int(num2) * int(num1))) stk.append stk append str(int(num2) * int(num1)) str int(num2) * int(num1) int(num2) int num2 int(num1) int num1 stk.append(i) stk.append stk append i print(stk.pop()) print stk.pop() stk.pop stk pop stk = [] [] stk num2 = stk.pop() stk.pop() num2 exp  = input().split() input().split() exp num1 = stk.pop() stk.pop() num1
exp  = input().split()
stk = []

for i in exp :
    if i in ('+', '-', '*') :
        num1 = stk.pop()
        num2 = stk.pop()
        
        if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
    else :
        stk.append(i)
        
print(stk.pop())
