import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

judge :: [String] -> State [Int] [String]
judge []         = return []
judge ("+" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a + b) : xs
judge ("-" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a - b) : xs
judge ("*" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a * b) : xs
judge ("/" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (div a b) : xs
judge [x     ] = return [x]
judge (x : xs) = do
  modify (read x :)
  judge xs

main = do
  r <- judge . words <$> getLine
  putStrLn $ head $ evalState r []

