
def revPoland(expr):
    stack = []

    for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

    return stack.pop()

expr = input().split()

print(revPoland(expr)) def revPoland(expr):
    stack = []

    for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

    return stack.pop() revPoland stack = [] stack [] for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

     l expr if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

     l.isdigit() l.isdigit l isdigit stack.append(int(l)) stack.append stack append int(l) int l a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop c = eval(str(b) + l + str(a)) c eval(str(b) + l + str(a)) eval str(b) + l + str(a) str(b) + l str(b) str b l str(a) str a stack.append(c) stack.append stack append c return stack.pop() stack.pop() stack.pop stack pop expr expr expr = input().split() expr input().split() ().split () input split print(revPoland(expr)) print revPoland(expr) revPoland expr def revPoland(expr):
    stack = []

    for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

    return stack.pop() def revPoland(expr):
    stack = []

    for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

    return stack.pop() revPoland expr = input().split() input().split() expr

def revPoland(expr):
    stack = []

    for l in expr:
        if l.isdigit():
            stack.append(int(l))
            # print(stack)
        else:
            a = stack.pop()
            b = stack.pop()
            c = eval(str(b) + l + str(a))
            stack.append(c)
            # print(stack)

    return stack.pop()

expr = input().split()

print(revPoland(expr))