How many ways to pick $X$ balls Suppose i have $3$ types of balls $A,B$ and $C$ and there are $n_a, n_b,$ and $n_c$ copies of these balls. Now i want to select $x$ balls from these $3$ types of balls $x < n_a + n_b + n_c$. Can anybody help me to arrive at the closed formula for this.
I thought, if I partition $x$ into $3$ partition it will do but in that case its quite possible that i can pick more ball of particular type than its actual count.

This problem can be easily solved with Principle of Inclusion Exclusion (PIE) and the Balls and Urns technique. The answer is:
$\dbinom{x+2}{2} - \dbinom{x-n_a+1}{2} - \dbinom{x-n_b+1}{2} - \dbinom{x-n_c+1}{2} + \dbinom{x-n_a-n_b}{2} + \dbinom{x-n_a-n_c}{2} + \dbinom{x-n_b-n_c}{2} - \dbinom{x-n_a-n_b-n_c-1}{2}$.
Hint: Each term corresponds to the number of non-negative integer solutions $(a,b,c)$ to $a+b+c = x$ with 0, 1, 2, or 3 of the following conditions enforced:
$a > n_a$
$b > n_b$
$c > n_c$
