bit operation and first missing element

Count number of bit in integer and find the first missing positive
element.