Situation 1:
[tex]\frac{g}{b}=2\rightarrow g=2b[/tex]
Situation 2:
[tex]\frac{g+24}{b}=5\\
\\
g+24=5b[/tex]
Replacing g in the second equation:
[tex]2b+24=5b\\
\\
3b=24\\
\\
b=8\\
\\
g=2b\\
\\
g=16[/tex]
In the Situation 1 there was 16 girls and 8 boys = 24 persons
In the Situation 2 there are 40 girs + 8 boys = 48 persons