If I have an integer in Java how do I count how many bits are zero except for leading zeros?

We know that integers in Java have 32 bits but counting the number of set bits in the number and then subtracting from 32 does not give me what I want because this will also include the leading zeros.

As an example, the number 5 has one zero bit because in binary it is `101`

.