For more complicated problems than this one in the original post the formula is $$ N=\frac1n\sum_{d|gcd(n_1,n_2,...,n_k)}^{}\phi(d)\binom{n/d}{n_1/d,n_2/d,...,n_k/d} $$ where:
## n ## - the number of balls,
## k ## - the number of colors,
## n_i ## - the number of balls of the i-th color,
##...