def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans Cal n1 = int(n1) n1 int(n1) int n1 n2 = int(n2) n2 int(n2) int n2 if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
     sym == '+' sym '+' ans = n1 + n2 ans n1 + n2 n1 n2 elif sym == '-':
        ans = n1 - n2
     sym == '-' sym '-' ans = n1 - n2 ans n1 - n2 n1 n2 ans = n1 * n2 ans n1 * n2 n1 n2 return ans ans sym sym n1 n1 n2 n2 stack = [] stack [] for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans) item raw_input().split() ().split () raw_input split if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans) item.isdigit() item.isdigit item isdigit stack.append(item) stack.append stack append item n2 = stack.pop() n2 stack.pop() stack.pop stack pop n1 = stack.pop() n1 stack.pop() stack.pop stack pop sym = item sym item ans = Cal(sym,n1,n2) ans Cal(sym,n1,n2) Cal sym n1 n2 stack.append(ans) stack.append stack append ans Ans = stack.pop() Ans stack.pop() stack.pop stack pop print n1 = stack.pop() stack.pop() n1 sym = item item sym n2 = stack.pop() stack.pop() n2 Ans = stack.pop() stack.pop() Ans ans = Cal(sym,n1,n2) Cal(sym,n1,n2) ans def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans Cal stack = [] [] stack
def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans