line = input()
A = line.split()

stack = []

for c in A:
    if c == '+':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs + rhs)
    elif c == '-':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs - rhs)
    elif c == '*':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs * rhs)
    else:
        stack.append(int(c))


print(stack.pop()) line = input() line input() input A = line.split() A line.split() line.split line split stack = [] stack [] for c in A:
    if c == '+':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs + rhs)
    elif c == '-':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs - rhs)
    elif c == '*':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs * rhs)
    else:
        stack.append(int(c)) c A if c == '+':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs + rhs)
    elif c == '-':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs - rhs)
    elif c == '*':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs * rhs)
    else:
        stack.append(int(c)) c == '+' c '+' rhs = stack.pop() rhs stack.pop() stack.pop stack pop lhs = stack.pop() lhs stack.pop() stack.pop stack pop stack.append(lhs + rhs) stack.append stack append lhs + rhs lhs rhs elif c == '-':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs - rhs)
     c == '-' c '-' rhs = stack.pop() rhs stack.pop() stack.pop stack pop lhs = stack.pop() lhs stack.pop() stack.pop stack pop stack.append(lhs - rhs) stack.append stack append lhs - rhs lhs rhs elif c == '*':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs * rhs)
     c == '*' c '*' rhs = stack.pop() rhs stack.pop() stack.pop stack pop lhs = stack.pop() lhs stack.pop() stack.pop stack pop stack.append(lhs * rhs) stack.append stack append lhs * rhs lhs rhs stack.append(int(c)) stack.append stack append int(c) int c print(stack.pop()) print stack.pop() stack.pop stack pop A = line.split() line.split() A lhs = stack.pop() stack.pop() lhs lhs = stack.pop() stack.pop() lhs lhs = stack.pop() stack.pop() lhs line = input() input() line stack = [] [] stack rhs = stack.pop() stack.pop() rhs rhs = stack.pop() stack.pop() rhs rhs = stack.pop() stack.pop() rhs
line = input()
A = line.split()

stack = []

for c in A:
    if c == '+':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs + rhs)
    elif c == '-':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs - rhs)
    elif c == '*':
        rhs = stack.pop()
        lhs = stack.pop()
        stack.append(lhs * rhs)
    else:
        stack.append(int(c))


print(stack.pop())