import java.io.*; import java.util.Scanner; public class Main_yukicoder822 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int k = sc.nextInt(); int max = n + (Integer.highestOneBit(n) << 1); if (max <= (Integer.highestOneBit(n) << 1) - 1 + k || (n == 0 && k == 0)) { pr.println("INF"); } else { int ans = 0; for (int x = n; x <= n + k; x++) { // if ((x & n) != n) { // continue; // } for (int y = x; y <= x + k; y++) { if ((x & y) == n) { ans++; } } } pr.println(ans); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }