Solution (source code)

= Solution

For $X=m$, the first $m-1$ digits must all differ from $3$ and the next digit must be $3$. <Independence> gives
$$
\boxed{\mathbb P(X=m)=\left(\frac23\right)^{m-1}\frac13,\qquad m=1,2,\ldots.}
$$
Thus $X$ has the <geometric distribution> counting trials up to and including the first success, with success <probability> $1/3$. For completeness, its <mean> follows from the <tail-sum formula>:
$$
\mathbb E[X]=\sum_{n=0}^{\infty}\mathbb P(X>n)=\sum_{n=0}^{\infty}\left(\frac23\right)^n=\boxed{3}.
$$
The sum of the <geometric series> also proves finiteness of this <expectation>.