You want the generalized result? OK, here it is:
To find the number of integer solutions to $$a_1+a_2+\cdots+a_r=n$$ with the restrictions that $a_1$ must be in $A_1$, $a_2$ must be in $A_2$, ..., $a_r$ must be in $A_r$ (where the $A_i$ are some given sets of permissible values for the variables), you form the generating function $$f(x)=\sum_{i\in A_1}x^i\sum_{i\in A_2}x^i\cdots\sum_{i\in A_r}x^i=\sum_mc(m)x^m$$ and then the number you are looking for is $c(n)$. The tricky part is going from the product in the display to the sum, but to do that you have to know what the sets $A_1,A_2,\dots,A_r$ are and then you have to exploit whatever special properties those sets might have. For example, the sums being multiplied together may turn out to be summable as geometric series, and the binomial theorem may then be of help in expressing the product as a series.