import Data.List

main :: IO()
main = getLine >>= print.solveRPN.words

solveRPN :: [String] -> Int
solveRPN = head.foldl' f []
    where f (x:y:ys) "+" = (y + x) : ys
          f (x:y:ys) "-" = (y - x) : ys
          f (x:y:ys) "*" = (y * x) : ys
          f xs        n  = read n  : xs