import Data.List
toInt::String->Int
toInt = read
rPolish::[Int]->[String]->Int
rPolish [x] [] = x
rPolish (x1:x2:xs) ("+":ys) = rPolish (x2+x1:xs) ys
rPolish (x1:x2:xs) ("-":ys) = rPolish (x2-x1:xs) ys
rPolish (x1:x2:xs) ("*":ys) = rPolish (x2*x1:xs) ys
rPolish xs (y:ys) = rPolish (toInt y:xs) ys
main = do
  getLine >>= print.(rPolish []).words

