Find the number of nonnegative integer solutions of the equation $$x_1 + x_2 + x_3 + x_4 + x_4 + x_5 = 9$$ satisfy the restrictions $x_1 \geq 1$ and $x_5 \leq 5$.
If $x_1 \geq 1$, $x_1' = x_1 - 1$ is a nonnegative integer. Substituting $x_1' + 1$ for $x_1$ in the equation
$$x_1 + x_2 + x_3 + x_4 + x_4 + x_5 = 9 \tag{1}$$
yields
\begin{align*}
x_1' + 1 + x_2 + x_3 + x_4 + x_5 & = 9\\
x_1' + x_2 + x_3 + x_4 + x_5 & = 8 \tag{2}
\end{align*}
Equation 2 is an equation in the nonnegative integers with
$$\binom{8 + 5 - 1}{5 - 1} = \binom{12}{4}$$
solutions, each of which is a solution of equation 1 that satisfies the requirement that $x_1 \geq 1$.
However, they include solutions of equation 1 in which $x_5 > 5$. Since the variables represent integers, if $x_5 > 5$, then $x_5 \geq 6$. Hence, we can eliminate those solutions which violate the restriction that $x_5 > 5$ by subtracting those solutions of equation 2 in which $x_5 \geq 6$.
Suppose $x_5 \geq 6$. Let $x_5' = x_5 - 6$. Then $x_5'$ is a nonnegative integer. Substituting $x_5' + 6$ for $x_5$ in equation 2 yields
\begin{align*}
x_1' + x_2 + x_3 + x_4 + x_5' + 6 & = 8\\
x_1' + x_2 + x_3 + x_5 + x_5' & = 2 \tag{3}
\end{align*}
Equation 3 is an equation in the nonnegative integers with
$$\binom{2 + 5 - 1}{5 - 1} = \binom{6}{4}$$
solutions.
Hence, the number of solutions of equation 1 which satisfy the restrictions $x_1 \geq 1$ and $x_5 \leq 5$ is
$$\binom{12}{4} - \binom{6}{4}$$