Let $m:=\min(n_1,n_2)$ and for $i\in\\{1,\dots,m\\}$ let $X_i$ take value $1$ if a red and a blue ball both with number $i$ will end up in box $C$. If this does not happen then let $X_i$ take value $0$. Then $$X:=X_1+\dots+X_m$$ equals the number of numbers doubly presented in box $C$. There are $2X$ balls that have a "numbermate" in the sense that there is another ball in box $C$ having the same number.
If you are after expectation then you can use linearity of expectation and symmetry to find that: $$\mathbb EX=m\Pr(X_1=1)$$
Also the $X_i$ are independent so that $X$ will have binomial distribution with parameters $m$ and $\Pr(X_1=1)$.
Can you find $\Pr(X_1=1)$ yourself?