**Problem**

Presented with the integer `n`

, find the 0-based position of the second rightmost zero bit in its binary representation (it is guaranteed that such a bit exists), counting from right to left.

Return the value of `2`

.^{position_of_the_found_bit}

**Example**

For `n = 37`

, the output should be

`secondRightmostZeroBit(n) = 8`

.

`37`

. The second rightmost zero bit is at position _{10} = 10**0**101_{2}`3`

(0-based) from the right in the binary representation of `n`

.

Thus, the answer is `2`

.^{3} = 8

**Input/Output**

**[time limit] 4000ms (rb)****[input] integer n**

*Guaranteed constraints:*

`4 ≤ n ≤ 2`

.^{30}**[output] integer**

**Solution**

`~(k = n|n+1) & k+1`

**Explanation**

Before we find the second rightmost, we need to be able to find the first.

To do so…

Suppose we have n = 37.

`37`

_{10} = 100101_{2
}`38`

_{10} = 100110_{2}

If we use an OR operator between the two numbers, 37 (n) and 38 (n+1), our first rightmost zero is “gone”. Let’s call this `k`

(i.e. k = n|n+1)

`37`

_{10} OR 38_{10} = 100111_{2}

Now, the complement of this is `~k = ~100111`

_{2} = 011000_{2}

And `k+1 = 101000`

_{2}

In k’s complement, other than our original first rightmost zero bit, all other “zero bits” will be all 1’s.

In k+1, our wanted “second rightmost zero” will have 1.

So if we use an AND operator between ~k and k+1, only the second zero will be 1 and all others will be 0’s.

`~k & (k+1) = 011000`

_{2} AND 101000_{2} = 001000_{2}