# Number of right jumps of random walk (with possibility of inaction) before hitting time

Suppose we have the random walk $$S_t=\sum\limits_{i=1}^t X_i$$, where $$X_i = \begin{cases} -1 & \text{with probability } p \\ 0 & \text{with probability } q \\ 1 & \text{with probability } 1-p-q\end{cases}$$

Define $$\tau$$ as the time at which $$S_n$$ hits one for the first time, i.e. $$\tau=\min\{t>0 : S_t=1\}$$.

Take $$n\in \mathbb{N}$$ and $$k\in\mathbb{N}\cup\{0\}$$ with $$k. Conditional on $$\tau=n$$, what is the probability that the number of time periods $$i in which $$X_i=0$$ is equal to $$k$$?, i.e. how do you compute $$\mathbb{P}\left( \left|\{i\in\{1,\dots,n\}:X_i=0\}\right|=k \right)\ ?$$