A generous boy wanted to give sweets to his classmates.

He offered 9 sweets to each boy and 12 sweets to each girl.

One third of the boys in the class accepted the sweets but only one quarter of the girls had the sweets.

If the boy gave out 87 sweets, how many classmates did he have?