while _ = $stdin.gets
  stack = []
  terms = _.chomp.split(/ /)
  terms.each do |t|
    case t
    when /^\A\d+\z/
      stack << t.to_i
    when '+'
      stack << stack.pop(2).inject(:+)
    when '-'
      stack << stack.pop(2).inject(:-)
    when '/'
      stack << stack.pop(2).inject(:/)
    when '*'
      stack << stack.pop(2).inject(:*)
    end
  end
  puts stack[0]
end