What have you tried so far? Please take the time to familiarize yourself with some basic forum rules. This is not a place to get people to do your homework for you.

http://www.mathhelpforum.com/math-he...ng-151422.html

That said, rather than finding a more elegant solution that generalizes to harder problems, for this we can simply break down into cases. Suppose the 3 identical balls are identified by the colour green. Four cases: 0 green, ... , 3 green. Then you've reduced it to problems that (supposedly) you already know how to solve.