list = input().split()
stack = []
for i in list:
    if ( i.isdigit() ):
        stack.append(int(i))
    elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
    elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
    elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop())

print(stack.pop()) list = input().split() list input().split() ().split () input split stack = [] stack [] for i in list:
    if ( i.isdigit() ):
        stack.append(int(i))
    elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
    elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
    elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop()) i list if ( i.isdigit() ):
        stack.append(int(i))
    elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
    elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
    elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop()) i.isdigit() i.isdigit i isdigit stack.append(int(i)) stack.append stack append int(i) int i elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
     i == '+' i '+' stack.append(stack.pop() + stack.pop()) stack.append stack append stack.pop() + stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
     i == '*' i '*' stack.append(stack.pop() * stack.pop()) stack.append stack append stack.pop() * stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop()) i == '-' i '-' stack.append( (-1)*stack.pop() + stack.pop()) stack.append stack append (-1)*stack.pop() + stack.pop() (-1)*stack.pop() -1 stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop print(stack.pop()) print stack.pop() stack.pop stack pop list = input().split() input().split() list stack = [] [] stack
list = input().split()
stack = []
for i in list:
    if ( i.isdigit() ):
        stack.append(int(i))
    elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
    elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
    elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop())

print(stack.pop())