Sometimes you count all possibilities, then subtract the invalid ones. This is called complementary counting.
Example: How many 3-digit numbers exist where not all digits are the same? Total 3-digit numbers: 900 (100-999). All same digits: 9 (111, 222, ..., 999). Answer: 900 - 9 = 891.
When direct counting is hard, count the complement and subtract.