start = 1010 and goal = 111. Each bit can be flipped on its own, so the answer is the number of positions where they differ.
Where do start and goal disagree?
diff & (diff - 1) drops the lowest 1
waits for the loop
start, flipped one bit per pass
flips = 0