A certain number of students want to divide 500 cookies equally among themselves at the end of class. Four students had to leave in the middle of class. The cookies were divided among the remaining students, and each student got 5 more cookies than they would have if everyone had stayed in class. How many students were originally in the class?