N, K = map(int, input().split()) if N == 0: if K == 0: print(1) else: print("INF") else: ans = 0 for y in range(N * K): if (y & N) != N: continue for x in range(max(0, y - K), y + 1)[:: -1]: if (y & x) == N: ans += 1 print(ans)