operand = []
for x in raw_input().split():
  if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand.pop()
    a2 = operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1)

print operand.pop() operand = [] operand [] for x in raw_input().split():
  if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand.pop()
    a2 = operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1) x raw_input().split() ().split () raw_input split if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand.pop()
    a2 = operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1) x.isdigit() x.isdigit x isdigit operand.append(int(x)) operand.append operand append int(x) int x a1 = operand.pop() a1 operand.pop() operand.pop operand pop a2 = operand.pop() a2 operand.pop() operand.pop operand pop if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1) x == '+' x '+' operand.append(a2 + a1) operand.append operand append a2 + a1 a2 a1 elif  x == '-':
      operand.append(a2 - a1)
     x == '-' x '-' operand.append(a2 - a1) operand.append operand append a2 - a1 a2 a1 elif  x == '*':
      operand.append(a2 * a1) x == '*' x '*' operand.append(a2 * a1) operand.append operand append a2 * a1 a2 a1 print operand.pop() operand.pop operand pop operand = [] [] operand a1 = operand.pop() operand.pop() a1 a2 = operand.pop() operand.pop() a2
operand = []
for x in raw_input().split():
  if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand.pop()
    a2 = operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1)

print operand.pop()