import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int k = Integer.parseInt(first[1]); if (n < k) { System.out.println("INF"); return; } int max = 1; while (n >= max) { max = max << 1; } int count = 0; for (int i = n; i <= max; i++) { for (int j = i; j - i <= k; j++) { if ((i & j) == n) { count++; } } } System.out.println(count); } }