command = raw_input().split(" ")
stack = []

for i in command:
    if i == "+":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a + b)
    elif i == "-":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a - b)
    elif i == "*":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a * b)
    elif i == "/":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a / b)
    else:
        stack.append(i)

print(stack.pop()) command = raw_input().split(" ") command raw_input().split(" ") ().split () raw_input split " " stack = [] stack [] for i in command:
    if i == "+":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a + b)
    elif i == "-":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a - b)
    elif i == "*":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a * b)
    elif i == "/":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a / b)
    else:
        stack.append(i) i command if i == "+":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a + b)
    elif i == "-":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a - b)
    elif i == "*":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a * b)
    elif i == "/":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a / b)
    else:
        stack.append(i) i == "+" i "+" b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a + b) stack.append stack append a + b a b elif i == "-":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a - b)
     i == "-" i "-" b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a - b) stack.append stack append a - b a b elif i == "*":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a * b)
     i == "*" i "*" b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a * b) stack.append stack append a * b a b elif i == "/":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a / b)
     i == "/" i "/" b = int(stack.pop()) b int(stack.pop()) int stack.pop() stack.pop stack pop a = int(stack.pop()) a int(stack.pop()) int stack.pop() stack.pop stack pop stack.append(a / b) stack.append stack append a / b a b stack.append(i) stack.append stack append i print(stack.pop()) print stack.pop() stack.pop stack pop b = int(stack.pop()) int(stack.pop()) b a = int(stack.pop()) int(stack.pop()) a a = int(stack.pop()) int(stack.pop()) a b = int(stack.pop()) int(stack.pop()) b b = int(stack.pop()) int(stack.pop()) b a = int(stack.pop()) int(stack.pop()) a a = int(stack.pop()) int(stack.pop()) a b = int(stack.pop()) int(stack.pop()) b command = raw_input().split(" ") raw_input().split(" ") command stack = [] [] stack
command = raw_input().split(" ")
stack = []

for i in command:
    if i == "+":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a + b)
    elif i == "-":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a - b)
    elif i == "*":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a * b)
    elif i == "/":
        b = int(stack.pop())
        a = int(stack.pop())
        stack.append(a / b)
    else:
        stack.append(i)

print(stack.pop())