line = input().split()
stack = []
for i in range(len(line)):
    obj = line[i]
    if obj.isnumeric():
        stack.append(obj)
    else:
        b = int(stack.pop(-1))
        a = int(stack.pop(-1))
        if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b)
print(stack[0]) line = input().split() line input().split() ().split () input split stack = [] stack [] for i in range(len(line)):
    obj = line[i]
    if obj.isnumeric():
        stack.append(obj)
    else:
        b = int(stack.pop(-1))
        a = int(stack.pop(-1))
        if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b) i range(len(line)) range len(line) len line obj = line[i] obj line[i] line i if obj.isnumeric():
        stack.append(obj)
    else:
        b = int(stack.pop(-1))
        a = int(stack.pop(-1))
        if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b) obj.isnumeric() obj.isnumeric obj isnumeric stack.append(obj) stack.append stack append obj b = int(stack.pop(-1)) b int(stack.pop(-1)) int stack.pop(-1) stack.pop stack pop -1 a = int(stack.pop(-1)) a int(stack.pop(-1)) int stack.pop(-1) stack.pop stack pop -1 if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b) obj == '+' obj '+' stack.append(a+b) stack.append stack append a+b a b elif obj == '-':
            stack.append(a-b)
         obj == '-' obj '-' stack.append(a-b) stack.append stack append a-b a b stack.append(a*b) stack.append stack append a*b a b print(stack[0]) print stack[0] stack 0 line = input().split() input().split() line a = int(stack.pop(-1)) int(stack.pop(-1)) a stack = [] [] stack b = int(stack.pop(-1)) int(stack.pop(-1)) b obj = line[i] line[i] obj
line = input().split()
stack = []
for i in range(len(line)):
    obj = line[i]
    if obj.isnumeric():
        stack.append(obj)
    else:
        b = int(stack.pop(-1))
        a = int(stack.pop(-1))
        if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b)
print(stack[0])