solve :: String -> Int
solve = head . foldl rpn [] . words
  where
    rpn (x:y:zs) "*" = y * x : zs
    rpn (x:y:zs) "-" = y - x : zs
    rpn (x:y:zs) "+" = y + x : zs
    rpn zs numstring = read numstring:zs

main = getLine >>= print . solve

