N,K = map(int, input().split()) if N < K: print("INF") else: ans = 0 for x in range(N+2*K+1): for y in range(x, x+K+1): if x&y == N: ans += 1 print(ans)