module Main where
--import Debug.Trace
import Data.List
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Control.Monad

data Symbol = Operand Int | Plus | Minus | Product deriving (Show)

solve :: [Symbol] -> Int
solve = iter [] where
    iter [Operand n] [] = n
    iter st ((Operand n):xs) = iter (push (Operand n) st) xs
    iter st (x:xs) = iter (op x) xs where
        op Plus    = push (Operand (n'' + n')) st''
        op Minus   = push (Operand (n'' - n')) st''
        op Product = push (Operand (n'' * n')) st''
        (Operand n' , st')  = pop st
        (Operand n'', st'') = pop st'

push :: Symbol -> [Symbol] -> [Symbol]
push s st = s:st

pop :: [Symbol] -> (Symbol, [Symbol])
pop (s:st) = (s, st) 

main :: IO() 
main = do
    l <- fmap words getLine
    let el = map f l where
            f "+" = Plus 
            f "-" = Minus 
            f "*" = Product 
            f  x  = Operand (read x)  
    print $ solve el

