This question already has an answer here:
$x_1,x_2,...,x_n$ are integer numbers in the range [0,B-1]. Count the number of solution for $x_1+x_2+...+x_n=k$.
I know this problem is similar to the one here Number of ways of partitioning a sum into ordered non-negative summands
But now there is constraint on the range of $x_i$. In the problem text it gives a hint to use principle of inclusion and exclusion. Does anyone have a clue?