How many 5 digits numbers are there, whose digits sum to 22? 
How many 5 digits numbers are there, whose digits sum to 22? Of course the first digit has to be larger than 0.
 A: The objects you are counting may be placed into bijection with solutions to $$x_1+x_2+x_3+x_4+x_5=22$$
such that $0\le x_i\le 9$ and also $x_1\ge 1$.  Via the substitution $x_1'=x_1-1$, we may instead solve $$x_1'+x_2+x_3+x_4+x_5=21$$ such that the variables are nonnegative integers, and also $x_1\le 8, x_i\le 9$ ($2\le i\le 5$).
Without the upper bound restriction, using stars and bars, there are ${26 \choose 22}$ solutions.  Now we must consider the various upper bounds, using inclusion-exclusion.  Let $A_1$ denote the set of solutions where $x_1'>8$, and $A_i$ denote the set of solutions where $x_i\ge 10$.  By considering the substitution $x_1''=x_1-9\ge 0$, we have $$x_1''+x_2+x_3+x_4+x_5=12$$
Again using the stars-and-bars approach, we have $|A_1|={17\choose 13}$.  If instead we want $x_2\ge 10$, we use the substitution $x_2'=x_2-10\ge 0$ and $$x_1'+x_2'+x_3+x_4+x_5=11$$ and so $|A_2|={16\choose 12}$.  By symmetry, $|A_3|=|A_4|=|A_5|$.  
To complete the problem, you also need to compute all the various $|A_1\cap A_2|$ and $|A_2\cap A_3|$, and then combine all the data using the inclusion-exclusion principle, which I leave for you as an exercise.
A: Using generating functions:
$$[x^{22}](x+x^2+\cdots+x^9)(1+x+\cdots +x^9)^4=\\
[x^{21}]\frac{1-x^9}{1-x}\cdot \frac{(1-x^8)^4}{(1-x)^4}=\\
[x^{21}](1-x^9)(1-x^8)^4(1-x)^{-5}=\\
[x^{21}]\sum_{i=0}^1 {1\choose i}(-x^9)^i\sum_{j=0}^4 {4\choose j}(-x^8)^j\sum_{k=0}^{\infty}{4+k\choose k}x^k=\\
\{(i,j,k)=(0,0,21),(0,1,11),(0,2,1),(1,0,12),(1,1,2)\}\\
{25\choose 21}-{4\choose 1}{15\choose 11}+{4\choose 2}{5\choose 1}-{16\choose 12}+{4\choose 1}{6\choose 2}=
5460.$$
WA answer.
