#input
char_list = raw_input().split()

#calculation
stack = []
for x in char_list:
    if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))

#output
print stack[0] char_list = raw_input().split() char_list raw_input().split() ().split () raw_input split stack = [] stack [] for x in char_list:
    if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))

#output x char_list if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))

#output x == "+" x "+" a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(a+b) stack.append stack append a+b a b elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
     x=="-" x "-" a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(b-a) stack.append stack append b-a b a elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
     x=="*" x "*" a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(a*b) stack.append stack append a*b a b stack.append(int(x)) stack.append stack append int(x) int x print stack[0] stack 0 a = stack.pop() stack.pop() a char_list = raw_input().split() raw_input().split() char_list stack = [] [] stack a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b b = stack.pop() stack.pop() b
#input
char_list = raw_input().split()

#calculation
stack = []
for x in char_list:
    if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))

#output
print stack[0]