What is the total number of solutions for following equation
$$x_1+x_2+x_3+.....+x_k=n$$
with a maximum value of $m$, where $0\leq x \leq m$. No two variables should contain a maximum value $m$.
Example: $x_1+x_2+x_3=3$ with a maximum value $2$ ($n=3$, $m=2$, $k=3$)
Total possible ways is $7$: $$\{1,1,1\}, \{0,1,2\}, \{0,2,1\}, \{1,0,2\}, \{1,2,0\}, \{2,0,1\}, \{2,1,0\}$$
I've done it manually but I don't how to come up with a formula. I've been struggling for last one week. Is there any formula?