Then take an empty bus and walk 5+ 18=23 people.
Only 1 23 can be divided by 23.
The remaining cars are either 1 or 23.
1+ 1=2 cars
1+23= 14 cars
2× 18+5=4 1 person
Or 24× 18+5=437 people.
"All teachers and students in a middle school" I think the latter is desirable:
There used to be 24 buses and 437 teachers and students in the school.