#! python3
# stack.py

symbols = input().split(' ')
stack = []

def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop()

for s in symbols:
    if s in ['+', '-', '*']:
        stack.append(calc(s))
    else:
        stack.append(int(s))

print(stack.pop()) symbols = input().split(' ') symbols input().split(' ') ().split () input split ' ' stack = [] stack [] def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop() calc global stack if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop() op == '+' op '+' return stack.pop()+stack.pop() stack.pop()+stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif op == '-':
        return -1 * stack.pop()+stack.pop()
     op == '-' op '-' return -1 * stack.pop()+stack.pop() -1 * stack.pop()+stack.pop() -1 * stack.pop() -1 stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif op == '*':
        return stack.pop()*stack.pop() op == '*' op '*' return stack.pop()*stack.pop() stack.pop()*stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop op op for s in symbols:
    if s in ['+', '-', '*']:
        stack.append(calc(s))
    else:
        stack.append(int(s)) s symbols if s in ['+', '-', '*']:
        stack.append(calc(s))
    else:
        stack.append(int(s)) s in ['+', '-', '*'] s ['+', '-', '*'] '+' '-' '*' stack.append(calc(s)) stack.append stack append calc(s) calc s stack.append(int(s)) stack.append stack append int(s) int s print(stack.pop()) print stack.pop() stack.pop stack pop def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop() def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop() calc symbols = input().split(' ') input().split(' ') symbols stack = [] [] stack
#! python3
# stack.py

symbols = input().split(' ')
stack = []

def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop()

for s in symbols:
    if s in ['+', '-', '*']:
        stack.append(calc(s))
    else:
        stack.append(int(s))

print(stack.pop())
