local band = bit.band local mmi, mma = math.min, math.max local n, k = io.read("*n", "*n") -- 2^a + n - (2^a - 1) <= k if n < k then print("INF") else local c = 0 for x = 0, 131071 do local ymin = mma(0, x - k) for y = ymin, x do if band(x, y) == n then c = c + 1 end end end print(c) end