ri = raw_input().split()
stack = []
for i in xrange(len(ri)):
  if ri[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)+int(b)))
  elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
  elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
  else:
    stack.append(ri[i])
print stack.pop() ri = raw_input().split() ri raw_input().split() ().split () raw_input split stack = [] stack [] for i in xrange(len(ri)):
  if ri[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)+int(b)))
  elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
  elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
  else:
    stack.append(ri[i]) i xrange(len(ri)) xrange len(ri) len ri if ri[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)+int(b)))
  elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
  elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
  else:
    stack.append(ri[i]) ri[i] == "+" ri[i] ri i "+" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(str(int(a)+int(b))) stack.append stack append str(int(a)+int(b)) str int(a)+int(b) int(a) int a int(b) int b elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
   ri[i] == "-" ri[i] ri i "-" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(str(int(a)-int(b))) stack.append stack append str(int(a)-int(b)) str int(a)-int(b) int(a) int a int(b) int b elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
   ri[i] == "*" ri[i] ri i "*" b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(str(int(a)*int(b))) stack.append stack append str(int(a)*int(b)) str int(a)*int(b) int(a) int a int(b) int b stack.append(ri[i]) stack.append stack append ri[i] ri i print stack.pop() stack.pop stack pop a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a ri = raw_input().split() raw_input().split() ri b = stack.pop() stack.pop() b b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a stack = [] [] stack
ri = raw_input().split()
stack = []
for i in xrange(len(ri)):
  if ri[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)+int(b)))
  elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
  elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
  else:
    stack.append(ri[i])
print stack.pop()