n_16 = input()[2:] n_10 = 0 for i in range(len(n_16)-1, -1, -1): if "A" <= n_16[i] <= "F": temp = 10 + ord(n_16[i]) - ord("A") else: temp = int(n_16[i]) n_10 += temp * 16**(len(n_16) - i - 1) print(n_10)