def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0]))

main() def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0])) main inps = list(input().split(" ")) inps list(input().split(" ")) list input().split(" ") ().split () input split " " stack = [] stack [] for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
   inp inps if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
   inp == "+" inp "+" a = int(stack.pop(-2)) a int(stack.pop(-2)) int stack.pop(-2) stack.pop stack pop -2 b = int(stack.pop(-1)) b int(stack.pop(-1)) int stack.pop(-1) stack.pop stack pop -1 stack.append(a+b) stack.append stack append a+b a b elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
     inp == "-" inp "-" a = int(stack.pop(-2)) a int(stack.pop(-2)) int stack.pop(-2) stack.pop stack pop -2 b = int(stack.pop(-1)) b int(stack.pop(-1)) int stack.pop(-1) stack.pop stack pop -1 stack.append(a-b) stack.append stack append a-b a b elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
     inp == "*" inp "*" a = int(stack.pop(-2)) a int(stack.pop(-2)) int stack.pop(-2) stack.pop stack pop -2 b = int(stack.pop(-1)) b int(stack.pop(-1)) int stack.pop(-1) stack.pop stack pop -1 stack.append(a*b) stack.append stack append a*b a b stack.append(inp) stack.append stack append inp print(int(stack[0])) print int(stack[0]) int stack[0] stack 0 main() main def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0])) def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0])) main
def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0]))

main()
