a = input()
a = a.split(' ')
stack = []
for i in a:
    if i == '+' or i == '-' or i == '*':
        s = int(stack.pop())
        t = int(stack.pop())
        if i == '+':
            u = t + s
        if i == '-':
            u = t - s
        if i == '*':
            u = t * s
        stack.append(u)
    else:
        stack.append(i)

print(stack.pop()) a = input() a input() input a = a.split(' ') a a.split(' ') a.split a split ' ' stack = [] stack [] for i in a:
    if i == '+' or i == '-' or i == '*':
        s = int(stack.pop())
        t = int(stack.pop())
        if i == '+':
            u = t + s
        if i == '-':
            u = t - s
        if i == '*':
            u = t * s
        stack.append(u)
    else:
        stack.append(i) i a if i == '+' or i == '-' or i == '*':
        s = int(stack.pop())
        t = int(stack.pop())
        if i == '+':
            u = t + s
        if i == '-':
            u = t - s
        if i == '*':
            u = t * s
        stack.append(u)
    else:
        stack.append(i) i == '+' or i == '-' or i == '*' i == '+' or i == '-' i == '+' i '+' i == '-' i '-' i == '*' i '*' s = int(stack.pop()) s int(stack.pop()) int stack.pop() stack.pop stack pop t = int(stack.pop()) t int(stack.pop()) int stack.pop() stack.pop stack pop if i == '+':
            u = t + s
         i == '+' i '+' u = t + s u t + s t s if i == '-':
            u = t - s
         i == '-' i '-' u = t - s u t - s t s if i == '*':
            u = t * s
         i == '*' i '*' u = t * s u t * s t s stack.append(u) stack.append stack append u stack.append(i) stack.append stack append i print(stack.pop()) print stack.pop() stack.pop stack pop a = a.split(' ') a.split(' ') a u = t - s t - s u u = t + s t + s u a = input() input() a s = int(stack.pop()) int(stack.pop()) s stack = [] [] stack t = int(stack.pop()) int(stack.pop()) t u = t * s t * s u
a = input()
a = a.split(' ')
stack = []
for i in a:
    if i == '+' or i == '-' or i == '*':
        s = int(stack.pop())
        t = int(stack.pop())
        if i == '+':
            u = t + s
        if i == '-':
            u = t - s
        if i == '*':
            u = t * s
        stack.append(u)
    else:
        stack.append(i)

print(stack.pop())