n, k = map(int, input().split()) if n < k: print('INF') exit() ans = 0 for x in range(2*n): for z in range(k+1): y = x+z if x&y == n: ans += 1 print(ans)