def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
   
s=list(input().split())

print(*r_poland(s)) def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
    r_poland stack=[] stack [] for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

     d s if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

     d.isdigit() d.isdigit d isdigit stack.append(int(d)) stack.append stack append int(d) int d elif d=="+":
            stack[-1]+=stack.pop(-2)
         d=="+" d "+" stack[-1]+=stack.pop(-2) stack[-1] stack -1 stack.pop(-2) stack.pop stack pop -2 elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
         d=="-" d "-" stack[-1]=stack.pop(-2)-stack[-1] stack[-1] stack -1 stack.pop(-2)-stack[-1] stack.pop(-2) stack.pop stack pop -2 stack[-1] stack -1 elif d=="*":
            stack[-1]*=stack.pop(-2)

     d=="*" d "*" stack[-1]*=stack.pop(-2) stack[-1] stack -1 stack.pop(-2) stack.pop stack pop -2 return stack stack s s s=list(input().split()) s list(input().split()) list input().split() ().split () input split print(*r_poland(s)) print *r_poland(s) r_poland(s) r_poland s s=list(input().split()) list(input().split()) s def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
    def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
    r_poland
def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
   
s=list(input().split())

print(*r_poland(s))