expr = input().split()
my_stack = []
def push(stack, item):
    return stack.append(item)

def pop(stack):
    return stack[:-1], stack[-1]

for item in expr:
    if item.isdigit():
        push(my_stack, int(item))
    elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
    elif item == '-':
        # not a - b
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, b - a)
    elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b)

print(my_stack[0]) expr = input().split() expr input().split() ().split () input split my_stack = [] my_stack [] def push(stack, item):
    return stack.append(item) push return stack.append(item) stack.append(item) stack.append stack append item stack stack item item def pop(stack):
    return stack[:-1], stack[-1] pop return stack[:-1], stack[-1] return stack[:-1], stack[-1] stack[:-1] stack :-1 -1 stack[-1] stack -1 stack stack for item in expr:
    if item.isdigit():
        push(my_stack, int(item))
    elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
    elif item == '-':
        # not a - b
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, b - a)
    elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b) item expr if item.isdigit():
        push(my_stack, int(item))
    elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
    elif item == '-':
        # not a - b
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, b - a)
    elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b) item.isdigit() item.isdigit item isdigit push(my_stack, int(item)) push my_stack int(item) int item elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
     item == '+' item '+' my_stack, a = pop(my_stack) my_stack pop(my_stack) pop my_stack a my_stack, b = pop(my_stack) my_stack pop(my_stack) pop my_stack b push(my_stack, a + b) push my_stack a + b a b elif item == '-':
        # not a - b
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, b - a)
     item == '-' item '-' my_stack, a = pop(my_stack) my_stack pop(my_stack) pop my_stack a my_stack, b = pop(my_stack) my_stack pop(my_stack) pop my_stack b push(my_stack, b - a) push my_stack b - a b a elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b) item == '*' item '*' my_stack, a = pop(my_stack) my_stack pop(my_stack) pop my_stack a my_stack, b = pop(my_stack) my_stack pop(my_stack) pop my_stack b push(my_stack, a * b) push my_stack a * b a b print(my_stack[0]) print my_stack[0] my_stack 0 a = pop(my_stack) pop(my_stack) a my_stack, a = pop(my_stack) pop(my_stack) my_stack my_stack, b = pop(my_stack) pop(my_stack) my_stack b = pop(my_stack) pop(my_stack) b a = pop(my_stack) pop(my_stack) a b = pop(my_stack) pop(my_stack) b a = pop(my_stack) pop(my_stack) a expr = input().split() input().split() expr my_stack, a = pop(my_stack) pop(my_stack) my_stack my_stack, b = pop(my_stack) pop(my_stack) my_stack my_stack = [] [] my_stack def pop(stack):
    return stack[:-1], stack[-1] def pop(stack):
    return stack[:-1], stack[-1] pop my_stack, a = pop(my_stack) pop(my_stack) my_stack b = pop(my_stack) pop(my_stack) b my_stack, b = pop(my_stack) pop(my_stack) my_stack def push(stack, item):
    return stack.append(item) def push(stack, item):
    return stack.append(item) push
expr = input().split()
my_stack = []
def push(stack, item):
    return stack.append(item)

def pop(stack):
    return stack[:-1], stack[-1]

for item in expr:
    if item.isdigit():
        push(my_stack, int(item))
    elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
    elif item == '-':
        # not a - b
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, b - a)
    elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b)

print(my_stack[0])