N,K = map(int, input().split())

if N == 0 and K > 0:
    print("INF")
else:
    ans = 0
    for x in range(N+2000):
        for y in range(x, x+K+1):
            if x&y == N:
                ans += 1

    print(ans)