How to count all integers less than a given integer and having two contigous digits as $y$?
So say you want to count all numbers of the form $x_1\cdot ab\cdot x_2$ less than $n$, where $x_1$ and $x_2$ are numbers with a fixed number of digits, and $ab$ are two contiguous digits.

Cut $n$ in the same positions as your $x_1\cdot ab \cdot x_2$ pattern to get $n_1\cdot pq\cdot n_2$.

Now when is $x_1\cdot ab\cdot x_2 &lt; n_1\cdot pq\cdot n_2$?


Either $x_1 &lt; n_1$, then any choice for $x_2$ goes. I.e., $10^{\text{number-of-digits}(x_2)}$ choices for $x_2$ whenever $x_1&lt;n_1$. In total you get $n_1\times10^{\text{number-of-digits}(x_2)}$ choices for this case, or $(n_1-10^{\text{number-of-digits}(x_1)-1})\times10^{\text{number-of-digits}(x_2)}$ choices if you don't allow for leading zeros.
Or $x_1=n_1$, in which case it depends on $ab$ and $pq$.


If $ab&lt;pq$ then any choice for $x_2$ goes, so you get an additional $10^{\text{number-of-digits}(x_2)}$ choices.
If $ab=pq$ then you have to have $x_2&lt;n_2$ which gives you an additional $n_2$ choices.
If $ab&gt;pq$ then no choice of $x_2$ will work.



In short, with leading zeros allowed:


If $ab&lt;pq$ :
$$n_1\times10^{\text{number-of-digits}(x_2)} + 10^{\text{number-of-digits}(x_2)}$$
If $ab=pq$ :
$$n_1\times10^{\text{number-of-digits}(x_2)} + n_2$$
If $ab&gt;pq$ :
$$n_1\times10^{\text{number-of-digits}(x_2)}$$


For example with $x11xx$ and $54432$ you get:
$$5\times 10^2 + 10^2 = 600$$