I need help figuring out how to find the number of share to purchase to bring down an average to a certain number.

I have 1,200 shares of xyz at \$9.34 and need to know how many to purchase at \$8.5 to bring down the average of all shares to \$9.00.

How would I write a formula to solve for this and be able to interchange the variables as well.

Thanks in advance.