I seem to have slightly different experiences when it comes to this. I would just say remain friends with Y if you think she could become a good friend of yours. Try to get things that the three of you can do together. Include X in as many things as possible.
--actually, screw it

I don't know enough about Y, X, or Z to really make any sort of suggestions.. Every situation is different, it is up to you to decide the best course

Good luck.