equ = input().split()

stack = []


def push(x, stack):
    stack.append(x)
    return stack
def pop(stack):
    val = stack.pop()
    return val,stack

for symbol in equ:
    if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack)

print(stack[0]) equ = input().split() equ input().split() ().split () input split stack = [] stack [] def push(x, stack):
    stack.append(x)
    return stack push stack.append(x) stack.append stack append x return stack stack x x stack stack def pop(stack):
    val = stack.pop()
    return val,stack pop val = stack.pop() val stack.pop() stack.pop stack pop return val,stack return val,stack val stack stack stack for symbol in equ:
    if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack) symbol equ if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack) symbol.isnumeric() symbol.isnumeric symbol isnumeric stack = push(int(symbol),stack) stack push(int(symbol),stack) push int(symbol) int symbol stack val1, stack = pop(stack) val1 pop(stack) pop stack stack val2, stack = pop(stack) val2 pop(stack) pop stack stack if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack) symbol == '+' symbol '+' stack = push(val1+val2, stack) stack push(val1+val2, stack) push val1+val2 val1 val2 stack elif symbol == '-':
            stack = push(val2-val1, stack)
         symbol == '-' symbol '-' stack = push(val2-val1, stack) stack push(val2-val1, stack) push val2-val1 val2 val1 stack elif symbol == '*':
            stack = push(val1*val2, stack) symbol == '*' symbol '*' stack = push(val1*val2, stack) stack push(val1*val2, stack) push val1*val2 val1 val2 stack print(stack[0]) print stack[0] stack 0 stack = [] [] stack stack = push(val1*val2, stack) push(val1*val2, stack) stack val1, stack = pop(stack) pop(stack) val1 def push(x, stack):
    stack.append(x)
    return stack def push(x, stack):
    stack.append(x)
    return stack push stack = push(val2-val1, stack) push(val2-val1, stack) stack equ = input().split() input().split() equ stack = pop(stack) pop(stack) stack stack = pop(stack) pop(stack) stack stack = push(int(symbol),stack) push(int(symbol),stack) stack val2, stack = pop(stack) pop(stack) val2 stack = push(val1+val2, stack) push(val1+val2, stack) stack def pop(stack):
    val = stack.pop()
    return val,stack def pop(stack):
    val = stack.pop()
    return val,stack pop
equ = input().split()

stack = []


def push(x, stack):
    stack.append(x)
    return stack
def pop(stack):
    val = stack.pop()
    return val,stack

for symbol in equ:
    if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack)

print(stack[0])
