In case the percentage of B is not the same as that of A, you'll have to change the second equation, that is:
x = y
Into the appropriate new percentage.
If it were for example 75% of B and 25 % of A, this becomes:
3x = y
(where x still represents the number of items A)