main :: IO ()
main = getLine >>= print . head . foldl calc [] . words

calc :: [Int] -> String -> [Int]
calc [] y = [read y]
calc xs@(_:[]) y = read y : xs
calc xa@(x1:x2:xs) y
  | y == "+" = x2 + x1 : xs
  | y == "-" = x2 - x1 : xs
  | y == "*" = x2 * x1 : xs
  | otherwise = read y : xa

