You don't say how you're "counting". There are various ways.
You need a summary field that counts the primary key and you need to place that on a sub-summary part sorted by class. That's if you on a layout based on students.
If you're on a layout based on classes, you need a calculation field that counts related students.
do you have the field in a subsummary part on the report layout? and are you sorting by the class?
An aggregate, such as Count(), will mean different values based on where it's placed on a layout. The same field in a subsummary (with sort) will be just those records. Put that field in a grand summary or footer and you get the TOTAL of all records in the found set (regardless of sort).