l=list(input().split())
l=l[::-1]
stack=[]
while len(l)>0:
  n=l.pop()
  if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n)
print(stack[-1]) l=list(input().split()) l list(input().split()) list input().split() ().split () input split l=l[::-1] l l[::-1] l ::-1 -1 stack=[] stack [] while len(l)>0:
  n=l.pop()
  if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n) len(l)>0 len(l) len l 0 n=l.pop() n l.pop() l.pop l pop if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n) n in ["+","-","*"] n ["+","-","*"] "+" "-" "*" a=int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop b=int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
   n=="+" n "+" stack.append(a+b) stack.append stack append a+b a b elif n=="-":
      stack.append(b-a)
     n=="-" n "-" stack.append(b-a) stack.append stack append b-a b a stack.append(a*b) stack.append stack append a*b a b stack.append(n) stack.append stack append n print(stack[-1]) print stack[-1] stack -1 stack=[] [] stack a=int(stack.pop()) int(stack.pop()) a b=int(stack.pop()) int(stack.pop()) b n=l.pop() l.pop() n l=list(input().split()) list(input().split()) l l=l[::-1] l[::-1] l
l=list(input().split())
l=l[::-1]
stack=[]
while len(l)>0:
  n=l.pop()
  if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n)
print(stack[-1])
