while True: try: s = input().strip() except EOFError: break #开始处理每一组输入 def getweight(ch): if ord(ch) >= ord('A') and ord(ch) <= ord('F'): return 10 + ord(ch) - ord('A') else: return int(ch) s = s.upper() num = 0 for i in range(2,len(s)): ch = s[i] num += getweight(ch) if i+1 < len(s): num = num * 16 print(num)