Study of the X(3872) and Y(4260) in B0 -> J/psi pi+ pi K0 and B--> J/psi pi+ pi K- decays