def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1])
l=list(input().split())
stacker(l) def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1]) stacker stack=[0] stack [0] 0 a=0 a 0 b=0 b 0 for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
   i l if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
   i=="+" i "+" a=int(stack[-1]) a int(stack[-1]) int stack[-1] stack -1 b=int(stack[-2]) b int(stack[-2]) int stack[-2] stack -2 stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop stack.append(a+b) stack.append stack append a+b a b elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
     i=="-" i "-" a=int(stack[-1]) a int(stack[-1]) int stack[-1] stack -1 b=int(stack[-2]) b int(stack[-2]) int stack[-2] stack -2 stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop stack.append(-a+b) stack.append stack append -a+b -a a b elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
     i=="*" i "*" a=int(stack[-1]) a int(stack[-1]) int stack[-1] stack -1 b=int(stack[-2]) b int(stack[-2]) int stack[-2] stack -2 stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop stack.append(a*b) stack.append stack append a*b a b stack.append(i) stack.append stack append i print(stack[-1]) print stack[-1] stack -1 l l l=list(input().split()) l list(input().split()) list input().split() ().split () input split stacker(l) stacker l def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1]) def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1]) stacker l=list(input().split()) list(input().split()) l
def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1])
l=list(input().split())
stacker(l)
