Before opening the switch S, the two capacitors are connected to battery serially. The effective capacitance is
C =
=
µF
The charge stored in each capacitor is equal because same current flows through each capacitor.
Qtot = CV = 2 μF × 9 V = 18 μF
After opening the switch S, the voltage capacitors are same as that of voltage across resistors, that is, 3 V and 6 V, respectively.
The charge stored in this situation in 3 μF capacitor is
3 μF × 3 V = 9 μC
and the charge in 6 μF is
6 μF × 6 V = 36 μC
Therefore, the total charge flow from y to x is
9 μC +18 μC = 27 μC