N, K = map(int, input().split()) if N == 0: if K == 0: print(1) else: print("INF") else: count = 0 max_x = N + 2 * K # Covering x up to N + 2K to handle all possible y = x + K for x in range(N, max_x + 1): if (x & N) != N: continue # x must have all bits of N set max_y = min(x + K, max_x) for y in range(x, max_y + 1): if (x & y) == N: count += 1 print(count)