import sys#导入sys模块

for line in sys.stdin:#循环输入,并且每次读取整行输入
    a = line.strip()#删除读取整行两侧的空格
    print(int(a,16))#直接把输入的十六进制整数,转变为十进制输出