Let $\{X_n:n=0,1,2,\ldots\}$ be a Markov chain on $\{0,1,2\}$ with initial distribution $\alpha = \begin{pmatrix}1&0&0\end{pmatrix}$ and transition matrix
$$
P = \begin{pmatrix}
1-q & q & 0\\
1-q & 0 & q\\
0 & 0 & 1
\end{pmatrix}.
$$
This is a terminating Markov chain, i.e. one in which all states are transient except for one which is absorbing. We can write $P$ as
$$
P = \begin{pmatrix}
T & \mathbf T^0\\
\mathbb 0 & 1
\end{pmatrix},
$$
where $T$ is the substochastic matrix corresponding to transitions between transient states and $\mathbf T^0$ the (row) vector corresponding to transitions from transient states to the absorbing states. Let $\tau = \inf\{n:X_n=2\}$, then the distribution of $\tau$ is
\begin{align}
\mathbb P(\tau = k) &= \alpha T^{k-1}\mathbf T^0\\
&= \frac{q^2 \left(\left(1-q+\sqrt{q (2-3 q)+1}\right)^k-\left(1-q-\sqrt{q (2-3 q)+1}\right)^k\right)}{2^k\sqrt{q (2-3 q)+1}}.
\end{align}