dic={'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
n="ABCDEF"
m=0
l=len(n)
for i in n:
    m=m+dic[i]*16**(l-1)
    l=l-1
print("%15d"%m)