import           Control.Applicative
import           Control.Monad

rpn :: [String] -> [String] -> Int
rpn [x] [] = read x
rpn s@(x1:x2:xs) (y:ys)
    | y == "+" = rpn (show (a + b) : xs) ys
    | y == "-" = rpn (show (a - b) : xs) ys
    | y == "*" = rpn (show (a * b) : xs) ys
  where
    a = read x2
    b = read x1
rpn xs (y:ys) = rpn (y : xs) ys

main :: IO ()
main = do
    xs <- words <$> getLine
    print $ rpn [] xs

