Number of integers in a certain range with certain properties
Hint: Decompose the range $[1,x]$ into more manageable ranges of the form $[N\cdot 10^{k+1},N\cdot 10^{k+1} + d \cdot 10^k)$, where $d &lt; 10$. Enumerate over the "popular" digit, and use inclusion-exclusion.