reversePolish :: [Int] -> String -> [Int]
reversePolish [] y = [(read y)]
reversePolish [x] y = (read y) : [x]
reversePolish axs@(x1:x2:xs) y
  | y == "+" = (x2 + x1) : xs
  | y == "-" = (x2 - x1) : xs
  | y == "*" = (x2 * x1) : xs
  | otherwise = (read y) : axs

main = do
  input <- getLine
  let inputs = words input
  let result = foldl reversePolish [] inputs
  print (result !! 0)