def solve(l):
    e = l.pop()
    if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e)

formula = input().split()
print(solve(formula)) def solve(l):
    e = l.pop()
    if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e) solve e = l.pop() e l.pop() l.pop l pop if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e) e == '*' e '*' return solve(l) * solve(l) solve(l) * solve(l) solve(l) solve l solve(l) solve l elif e == '+':
        return solve(l) + solve(l)
     e == '+' e '+' return solve(l) + solve(l) solve(l) + solve(l) solve(l) solve l solve(l) solve l elif e == '-':
        return - solve(l) + solve(l)
     e == '-' e '-' return - solve(l) + solve(l) - solve(l) + solve(l) - solve(l) solve(l) solve l solve(l) solve l return int(e) int(e) int e l l formula = input().split() formula input().split() ().split () input split print(solve(formula)) print solve(formula) solve formula formula = input().split() input().split() formula def solve(l):
    e = l.pop()
    if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e) def solve(l):
    e = l.pop()
    if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e) solve
def solve(l):
    e = l.pop()
    if e == '*':
        return solve(l) * solve(l)
    elif e == '+':
        return solve(l) + solve(l)
    elif e == '-':
        return - solve(l) + solve(l)
    else:
        return int(e)

formula = input().split()
print(solve(formula))