If you set b0 of the mask and AND it with the target, then you can tell if the target bit was set by the outcome. If it's set, increment your count. Move the bit in the mask to b1. Wash, rinse, repeat, until done.