A teacher usually divides his class into six groups of n students each. However, on Monday, three of the students were absent, so the teacher divided the remaining students into seven groups of m students each. On Tuesday, four students were absent, so he went back to n students per group, but there was one fewer group than he usually has. How many students are in the class?