I found a solution to my problem in this thread: How can I (algorithmically) count the number of ways n m-sided dice can add up to a given number?
But unfotunately I don't understand the last step.
$$x^n(1-x^{m})^{n}\left(\sum_{k=0}^{\infty} {n+k-1 \choose k} x^k\right)$$
I wrote it like this:
$$\left[\,\sum_{r = 0}^{n}\left(-1\right)^{r}{n \choose r}x^{mr+n}\,\right] \left[\,\sum_{k = 0}^{\infty}{n + k - 1 \choose k} x^{k}\,\right]$$
I don't why this follows:
$$\sum_{rm+k=S-n} {n \choose r} {n+k-1 \choose k} (-1)^{r}$$
And what does mean $rm+k=S-n$ in that sum. What is the upper limit?
Thanks in advance!
I can answer part of your question:
Not all sums have an upper limit. For example, take $\sum_{i+j=1}i+j$. To figure out what values of $i$ and $j$ to plug in, look at all combinations of 2 integers whose sum equals $1$. So for example, $0$ and $1$, $5$ and $-4$, $-4$ and $5$, etc.
So in your sum, $rm+k=S-n$ is a condition telling you that you can only pick values of $r,m$ and $k$ that satisfy that equation.
As for the last step, he's not saying it's equal to the previous line, he's saying it equals the coefficient of $x^S$ in the previous line, if you were to multiply everything out to see it.