import Control.Monad
import Control.Applicative
import Data.Char

main :: IO ()
main = do
  is <- words <$> getLine
  print $ solve is

solve :: [String] -> Int
solve inputs = go [] inputs
  where
    go [acc] [] = acc
    go (x:y) (c:cs)
      | c == "+" = go (x+head y:drop 1 y) cs
      | c == "-" = go (head y-x:drop 1 y) cs
      | c == "*" = go (x*head y:drop 1 y) cs
      | otherwise = go ([read c :: Int, x] ++ y) cs
    go ns (c:cs) = go (read c : ns) cs