while True:
    try:
        l = input()
        print(int(l,16))
    except:
        break