import Control.Applicative
solveRPN :: [String] -> Int
solveRPN expression = head (foldl foldingFunction [] expression)
  where foldingFunction (x:y:ys) "*" = (y * x) : ys
        foldingFunction (x:y:ys) "+" = (y + x) : ys
        foldingFunction (x:y:ys) "-" = (y - x) : ys
        foldingFunction xs numberString = read numberString : xs


main :: IO()
main = do
  line <- words <$> getLine
  print $ solveRPN line