# encoding: utf-8

input = raw_input().split()

stack = []
for n in input:
    if(n.isdigit()):
        stack.append(int(n))
    else:
        a = stack.pop()
        b = stack.pop()
        if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a)
print stack.pop() input = raw_input().split() input raw_input().split() ().split () raw_input split stack = [] stack [] for n in input:
    if(n.isdigit()):
        stack.append(int(n))
    else:
        a = stack.pop()
        b = stack.pop()
        if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a) n input if(n.isdigit()):
        stack.append(int(n))
    else:
        a = stack.pop()
        b = stack.pop()
        if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a) n.isdigit() n.isdigit n isdigit stack.append(int(n)) stack.append stack append int(n) int n a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a) n == '+' n '+' stack.append(b + a) stack.append stack append b + a b a elif n == '-':
            stack.append(b - a)
         n == '-' n '-' stack.append(b - a) stack.append stack append b - a b a elif n == '*':
            stack.append(b * a)
         n == '*' n '*' stack.append(b * a) stack.append stack append b * a b a stack.append(b / a) stack.append stack append b / a b a print stack.pop() stack.pop stack pop input = raw_input().split() raw_input().split() input stack = [] [] stack a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b
# encoding: utf-8

input = raw_input().split()

stack = []
for n in input:
    if(n.isdigit()):
        stack.append(int(n))
    else:
        a = stack.pop()
        b = stack.pop()
        if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a)
print stack.pop()