while 1:
    try:
        a = input()
        print(int(a,16))
    except:
        break