ans = gets.chomp.scan(/\+|\*|\d+/).inject([]) do |s, t| if s.size < 2 s << t else e,op = s.shift(2) s << (op == '+' ? (e.to_i * t.to_i) : (e.to_i + t.to_i)) end end puts ans.shift