def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False

def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop()

A = list(map(str,input().split()))

print(calc_reverse_polish_notation(A)) def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False is_operator if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False ele == "+" or ele == "-" or ele == "*" ele == "+" or ele == "-" ele == "+" ele "+" ele == "-" ele "-" ele == "*" ele "*" return True True return False False ele ele def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop() calc_reverse_polish_notation stack = [] stack [] for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
     i A if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
     is_operator(i) is_operator i a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop ans = eval("{0} {1} {2}".format(b, i, a)) ans eval("{0} {1} {2}".format(b, i, a)) eval "{0} {1} {2}".format(b, i, a) "{0} {1} {2}".format "{0} {1} {2}" format b i a stack.append(ans) stack.append stack append ans stack.append(i) stack.append stack append i return stack.pop() stack.pop() stack.pop stack pop A A A = list(map(str,input().split())) A list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split print(calc_reverse_polish_notation(A)) print calc_reverse_polish_notation(A) calc_reverse_polish_notation A def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False is_operator A = list(map(str,input().split())) list(map(str,input().split())) A def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop() def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop() calc_reverse_polish_notation
def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False

def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop()

A = list(map(str,input().split()))

print(calc_reverse_polish_notation(A))
