calcs = ["+", "-", "*", "/"]

#a="1 2 + 3 4 - *"
#a="1 2 +"
#lst = a.split()
lst = raw_input().split()

st=[]

def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot)

for x in lst:
    if x in calcs:
       calc(x)
    else:
       st.append(int(x))

print st.pop() calcs = ["+", "-", "*", "/"] calcs ["+", "-", "*", "/"] "+" "-" "*" "/" lst = raw_input().split() lst raw_input().split() ().split () raw_input split st=[] st [] def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot) calc tot=0 tot 0 tmp=0 tmp 0 first=True first True b = st.pop() b st.pop() st.pop st pop a = st.pop() a st.pop() st.pop st pop if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

     e   == "+" e "+" tot = a + b tot a + b a b elif e == "-":
         tot = a- b
     e == "-" e "-" tot = a- b tot a- b a b elif e == "*":
         tot = a * b
     e == "*" e "*" tot = a * b tot a * b a b elif e == "/":
         tot = a / b

     e == "/" e "/" tot = a / b tot a / b a b st.append(tot) st.append st append tot e e for x in lst:
    if x in calcs:
       calc(x)
    else:
       st.append(int(x)) x lst if x in calcs:
       calc(x)
    else:
       st.append(int(x)) x in calcs x calcs calc(x) calc x st.append(int(x)) st.append st append int(x) int x print st.pop() st.pop st pop lst = raw_input().split() raw_input().split() lst st=[] [] st def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot) def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot) calc calcs = ["+", "-", "*", "/"] ["+", "-", "*", "/"] calcs
calcs = ["+", "-", "*", "/"]

#a="1 2 + 3 4 - *"
#a="1 2 +"
#lst = a.split()
lst = raw_input().split()

st=[]

def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot)

for x in lst:
    if x in calcs:
       calc(x)
    else:
       st.append(int(x))

print st.pop()