Let the number of girls be x and the number of boys be y
The number of boys is the same as the number of girls.
x = y
The number of boys is twice the number of girls when 8 girls left.
2(x - 8) = y
x = y ---------------- (1)
2(x - 8) = y -------- (2)
Sub (1) into (2)
2(y - 8) = y
2y - 16 = y
2y - y = 16
y = 16
There were 16 boys and 16 girls initially.
16 + 16 = 32
There were a total of 32 students in the class initially.