For example, let's say I have a situation like this
Can I write an OCL expression that counts how many students a school has, such as:
School.students->count()
?
Or would it be incorrect? And in that case, how would I count the number of students?

Yes, the dot is the correct OCL syntax, here.
This is explained in the OCL specifications, section 7.4.10 on navigation operators:
Furthermore, section 7.5.3 on navigation of properties explain that:
There is just one issue here:
studentsis not formally defined. In principle you should use the role name indicated at the association end (next to the*), and if no such role is given in the class diagram, you should use the class name instead, sostudent.Not related:
count()is used with an argument regarding the objects that have to be counted in the set. If you mean the number of students associated with a given school, you should use->size()