import Control.Applicative

operate :: String -> [Int] -> [Int]
operate op (n2:n1:stack)
  | op == "+" = (n1+n2):stack
  | op == "-" = (n1-n2):stack
  | op == "*" = (n1*n2):stack
operate op stack = (read op :: Int):stack

operates :: [String] -> Int
operates ops = loop ops []
  where
    loop :: [String] -> [Int] -> Int
    loop [] [x]         = x
    loop (op:ops) stack = loop ops (operate op stack)

main :: IO ()
main = do
  ops <- words <$> getLine
  print $ operates ops

