We can find a formula to calculate it for any given n-bits binary.
Let's analyze it. It is actually simple. First to calculate the number of all possible different number we use
2^n = number of possible different binary numbers of n bits length.
Now, we know that all this possible numbers will have 11 or 00 on them except for two. These are the ones with the bits 0s and 1s are either 01010101… or 10101010…
That is when the bit in position x not equal the bit in position x+1.
So the final formula will be:
(2^n) - 2 = number of possible binary numbers with 11 or 00.
So the answer is (2^5) - 2 = 32 - 2 = 30.