$cnt = 0

def calc arr
  operators = %w(+ - *)
  stack = []
  arr.each { |item|
    # ??????????????£????????????????????????2???????????????????¨????????????????????????????????????\????????????
    if operators.include? item
      first = stack.pop
      second = stack.pop
      stack.push eval "#{second} #{item} #{first}"
    elsif
      # ??°????????£???????????????????????°???
      stack.push item
    end
  }

  stack
end

inputs = STDIN.gets.chomp.split(' ')

p calc(inputs).first