import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { new Main().run(); } void run() throws Exception { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long K = sc.nextLong(); if (N + 1 <= K) { System.out.println("INF"); return; } int max = 1; while (max <= N) max *= 2; max -= 1; long ans = 0; for (long y = N; y <= max; ++y) { for (long x = Math.max(0, y - K); x <= y; ++x) if ((x & y) == N) { ++ans; } } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }