isOperator str = str=="+" || str=="-" || str=="*"

operatorCalc :: Int -> Int -> String -> Int
operatorCalc a b op | op=="+"   = a+b
                    | op=="-"   = a-b
                    | op=="*"   = a*b
                    | otherwise = 0

reversePolishNotation::[String]->[String]
reversePolishNotation (a:[])       = [a]
reversePolishNotation (a:b:[])     = [a,b]
reversePolishNotation (a:b:c:expr) = if (isOperator c && not(isOperator b) && not(isOperator a))
                                        then reversePolishNotation(show(operatorCalc(read a)(read b)c):expr)
                                        else if isOperator b
                                            then a:b:c:expr
                                            else reversePolishNotation(a:reversePolishNotation(b:c:expr))

main = do{
    getLine>>=putStrLn.head.reversePolishNotation.words;
}