import operator
def poland(A):
    l = []
    ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul }
    for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
    return l.pop()
    

if __name__ == '__main__':
    A = input().split()
    print (poland(A[:])) import operator operator def poland(A):
    l = []
    ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul }
    for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
    return l.pop()
     poland l = [] l [] ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul } ops { "+": operator.add, "-": operator.sub, '*' : operator.mul } "+" "+" operator.add operator add "-" "-" operator.sub operator sub '*' '*' operator.mul operator mul for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
     i range(len(A)) range len(A) len A item = A.pop(0) item A.pop(0) A.pop A pop 0 if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
     item in ops item ops l.append(ops[item](l.pop(-2),l.pop())) l.append l append ops[item](l.pop(-2),l.pop()) [item] ops item l.pop(-2) l.pop l pop -2 l.pop() l.pop l pop l.append(int(item)) l.append l append int(item) int item return l.pop() l.pop() l.pop l pop A A if __name__ == '__main__':
    A = input().split()
    print (poland(A[:])) __name__ == '__main__' __name__ '__main__' A = input().split() A input().split() ().split () input split print (poland(A[:])) print poland(A[:]) poland A[:] A : A = input().split() input().split() A def poland(A):
    l = []
    ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul }
    for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
    return l.pop()
     def poland(A):
    l = []
    ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul }
    for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
    return l.pop()
     poland
import operator
def poland(A):
    l = []
    ops = { "+": operator.add, "-": operator.sub, '*' : operator.mul }
    for i in range(len(A)):
        item = A.pop(0)
        if item in ops:
            l.append(ops[item](l.pop(-2),l.pop()))
        else:
            l.append(int(item))
    return l.pop()
    

if __name__ == '__main__':
    A = input().split()
    print (poland(A[:]))