I have $n_1$ red balls in a box $A$. These balls are numbered from $1, \cdots n_1$. Let make a copy version of box $A$, called box $D$ (It means that the box $D$ will contain $n_1$ red balls from $1, \cdots n_1$).
Throw these balls to a box $B$ with loss probability $p$. Now, we change the color of these balls in the box B to green color.
Throw these balls from box $D$ and $B$ to a box $C$. The loss probability of balls in each box is also $p$. How many balls in box C will have the same number? Thank you so much
The below figure shows a toy example of the question. The balls (4,7) has same number, so the ans. is 2 for the example

The probability that the ball with e.g. number $1$ in box A will reach box B (to get the color green) is $1-p$. On condition that it indeed reaches box B it has a chance of $1-p$ to reach box C (as a green ball). Then the unconditional probability that a green ball with number $1$ will be present in box C is $(1-p)^2$.
The probability that the ball with number $1$ in box D will reach box C (as a red ball) is $1-p$. On base of independence we conclude that the probability that box C will eventually contain a red and a green ball with number $1$ is $(1-p)^3$.
Then we end up with expectation $n_1(1-p)^3$ for the number of pairs of balls in box C that have an equal number.