# -*- coding: utf-8 -*-


input_list = input().split()
stack = list()
for i in input_list:
    if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()
        if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b)
print(stack.pop()) input_list = input().split() input_list input().split() ().split () input split stack = list() stack list() list for i in input_list:
    if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()
        if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b) i input_list if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()
        if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b) i.isdigit() i.isdigit i isdigit stack.append(int(i)) stack.append stack append int(i) int i b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b) i == '+' i '+' stack.append(a + b) stack.append stack append a + b a b elif i == '-':
            stack.append(a - b)
         i == '-' i '-' stack.append(a - b) stack.append stack append a - b a b elif i == '*':
            stack.append(a * b) i == '*' i '*' stack.append(a * b) stack.append stack append a * b a b print(stack.pop()) print stack.pop() stack.pop stack pop stack = list() list() stack input_list = input().split() input().split() input_list a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b
# -*- coding: utf-8 -*-


input_list = input().split()
stack = list()
for i in input_list:
    if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()
        if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b)
print(stack.pop())