The question is: in how many different ways can I put $N$ indistinguishable balls into $M$ distinguishable boxes such that each box contains no more than $K$ balls it it?
A more general problem: if $K$ is different for different boxes, $K_i$ for the box $i$, $i=1,...,M$.
I tried to find a way to use "stars and bars" method here, but didn't succeed. I would be grateful if anyone could explain how to solve such a task or provide a reference.