def doc_string():
    """
    I can fly.
    """

list = []
stack = []
if __name__ == "__main__":
    list = raw_input().split()

    for var in list:
        try:
            stack.append(int(var))
        except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

    print stack.pop() def doc_string():
    """
    I can fly.
    """ doc_string """
    I can fly.
    """ list = [] list [] stack = [] stack [] if __name__ == "__main__":
    list = raw_input().split()

    for var in list:
        try:
            stack.append(int(var))
        except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

    print stack.pop() __name__ == "__main__" __name__ "__main__" list = raw_input().split() list raw_input().split() ().split () raw_input split for var in list:
        try:
            stack.append(int(var))
        except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

     var list try:
            stack.append(int(var))
        except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

     except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

     if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
             var == "+" var "+" 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 if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
             var == "-" var "-" 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 if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

     var == "*" var "*" 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 stack.append(int(var)) stack.append stack append int(var) int var print stack.pop() stack.pop stack pop list = [] [] list a = stack.pop() stack.pop() a a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b def doc_string():
    """
    I can fly.
    """ def doc_string():
    """
    I can fly.
    """ doc_string a = stack.pop() stack.pop() a list = raw_input().split() raw_input().split() list b = stack.pop() stack.pop() b b = stack.pop() stack.pop() b stack = [] [] stack
def doc_string():
    """
    I can fly.
    """

list = []
stack = []
if __name__ == "__main__":
    list = raw_input().split()

    for var in list:
        try:
            stack.append(int(var))
        except:
            if var == "+":
                a = stack.pop()
                b = stack.pop()
                stack.append(b + a)
            if var == "-":
                a = stack.pop()
                b = stack.pop()
                stack.append(b - a)
            if var == "*":
                a = stack.pop()
                b = stack.pop()
                stack.append(b * a)

    print stack.pop()