arr = input().split()
stack = list()
for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue
print(stack.pop()) arr = input().split() arr input().split() ().split () input split stack = list() stack list() list for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue el arr if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue el.isdigit() el.isdigit el isdigit stack.append(int(el)) stack.append stack append int(el) int el continue elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
     el == "*" el "*" stack.append(stack.pop() * stack.pop()) stack.append stack append stack.pop() * stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop continue elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
     el == "+" el "+" stack.append(stack.pop() + stack.pop()) stack.append stack append stack.pop() + stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop continue elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue el == "-" el "-" stack.append(-stack.pop() + stack.pop()) stack.append stack append -stack.pop() + stack.pop() -stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop continue print(stack.pop()) print stack.pop() stack.pop stack pop stack = list() list() stack arr = input().split() input().split() arr
arr = input().split()
stack = list()
for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue
print(stack.pop())
