import Data.Char

main = interact $ unlines . map (show . rp [] . words) . lines

rp acc [] = head acc
rp acc (x:xs)
 | any isDigit x = rp (read x : acc) xs
 | otherwise = rp ((op x) (head (tail acc)) (head acc) : (tail (tail acc))) xs
 where op x = case x of {"+" -> (+); "-" -> (-); "*" -> (*); "/" -> (/)}