Let the number of boys be B and the number of girls be G, making the total number of students B + G. The overall total marks are found by adding the boys' total marks to the girls' total marks, giving B times x + G times y. We set this equal to the overall average multiplied by the total number of students, giving B times x + G times y = (B + G) times z. Expanding the right side and rearranging the terms to group the boys and girls together yields B times (x - z) = G times (z - y). Solving for the ratio of the number of girls to the total number of students, we divide G by B + G, which results in the fraction (z - x) / (y - x).