I've just managed to stump myself. Lets say you have M (identical) marbles and N boxes. How many ways can you put the marbles in the boxes if each box can have at most k (k <= M) marbles? for k=M we can take M .'s to be the marbles and N-1 |'s to be the boxes so a valid configuration is a sequence like ..|.|...||.. so we end up with (M+N-1) choose M. for k=1, we must have M<N, and we have N choices for the first marble, N-1 choices for the second, ... which is just N choose M possibilities. is there a formula for arbitrary k?