The Number of boys in the class is: 18
Let's call "g" to the number of girls in the class.
The problem says that there is "w" fewer boys than girls, so we have:
g-w=18
Then, the number of girls in the class is:
g=18+w
Let's call "x" to the total number of studens in the class:
x=g+18
When we substitute g=18+w into x=g+18, we obtain:
x= (18+w)+18
The total number of studens in the class is:
x=w+36