
def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

A = input().split()
Stack = []

for i in range(len(A)):
    if A[i] == '+':
        add(Stack)
    elif A[i] == '-':
        subtract(Stack)
    elif A[i] == '*':
        multiple(Stack)
    else:
        Stack.append(int(A[i]))

print(str(Stack[0])) def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack add tmp = Stack[-1] + Stack[-2] tmp Stack[-1] + Stack[-2] Stack[-1] Stack -1 Stack[-2] Stack -2 Stack.pop(-1) Stack.pop Stack pop -1 Stack.pop(-1) Stack.pop Stack pop -1 Stack.append(tmp) Stack.append Stack append tmp return Stack Stack Stack Stack def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack subtract tmp = Stack[-2] - Stack[-1] tmp Stack[-2] - Stack[-1] Stack[-2] Stack -2 Stack[-1] Stack -1 Stack.pop(-1) Stack.pop Stack pop -1 Stack.pop(-1) Stack.pop Stack pop -1 Stack.append(tmp) Stack.append Stack append tmp return Stack Stack Stack Stack def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack multiple tmp = Stack[-1] * Stack[-2] tmp Stack[-1] * Stack[-2] Stack[-1] Stack -1 Stack[-2] Stack -2 Stack.pop(-1) Stack.pop Stack pop -1 Stack.pop(-1) Stack.pop Stack pop -1 Stack.append(tmp) Stack.append Stack append tmp return Stack Stack Stack Stack A = input().split() A input().split() ().split () input split Stack = [] Stack [] for i in range(len(A)):
    if A[i] == '+':
        add(Stack)
    elif A[i] == '-':
        subtract(Stack)
    elif A[i] == '*':
        multiple(Stack)
    else:
        Stack.append(int(A[i])) i range(len(A)) range len(A) len A if A[i] == '+':
        add(Stack)
    elif A[i] == '-':
        subtract(Stack)
    elif A[i] == '*':
        multiple(Stack)
    else:
        Stack.append(int(A[i])) A[i] == '+' A[i] A i '+' add(Stack) add Stack elif A[i] == '-':
        subtract(Stack)
     A[i] == '-' A[i] A i '-' subtract(Stack) subtract Stack elif A[i] == '*':
        multiple(Stack)
     A[i] == '*' A[i] A i '*' multiple(Stack) multiple Stack Stack.append(int(A[i])) Stack.append Stack append int(A[i]) int A[i] A i print(str(Stack[0])) print str(Stack[0]) str Stack[0] Stack 0 A = input().split() input().split() A Stack = [] [] Stack def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack add def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack subtract def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack multiple

def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

A = input().split()
Stack = []

for i in range(len(A)):
    if A[i] == '+':
        add(Stack)
    elif A[i] == '-':
        subtract(Stack)
    elif A[i] == '*':
        multiple(Stack)
    else:
        Stack.append(int(A[i]))

print(str(Stack[0]))