l=map(str,raw_input().split())
chk=[]
op='-+*'
while len(l):
    k=l.pop(0)
    if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k)
print chk[0] l=map(str,raw_input().split()) l map(str,raw_input().split()) map str raw_input().split() ().split () raw_input split chk=[] chk [] op='-+*' op '-+*' while len(l):
    k=l.pop(0)
    if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k) len(l) len l k=l.pop(0) k l.pop(0) l.pop l pop 0 if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k) k in op k op b=chk.pop() b chk.pop() chk.pop chk pop a=chk.pop() a chk.pop() chk.pop chk pop chk.append(str(eval(a+k+b))) chk.append chk append str(eval(a+k+b)) str eval(a+k+b) eval a+k+b a+k a k b chk.append(k) chk.append chk append k print chk[0] chk 0 chk=[] [] chk k=l.pop(0) l.pop(0) k l=map(str,raw_input().split()) map(str,raw_input().split()) l op='-+*' '-+*' op b=chk.pop() chk.pop() b a=chk.pop() chk.pop() a
l=map(str,raw_input().split())
chk=[]
op='-+*'
while len(l):
    k=l.pop(0)
    if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k)
print chk[0]