2. In a class, there are two types of students: one type always lies, and the other type never lies. Each student knows what type the other students are. During a gathering today, each student has to state what type the other students are, and all students together said "liar" 240 times. At a similar gathering yesterday, one student was absent, but all students together said "liar" 216 times. Then the total number of students who participated in today's gathering is.
2. 22 .

Consider four possible scenarios:
(1) If student $A$ is a liar and student $B$ is not a liar, then $A$ will say $B$ is a liar;
(2) If student $A$ is a liar and student $B$ is also a liar, then $A$ will say $B$ is not a liar;
(3) If student $A$ is not a liar and student $B$ is also not a liar, then $A$ will say $B$ is not a liar;
(4) If student $A$ is not a liar and student $B$ is a liar, then $A$ will say $B$ is a liar.

Thus, if there are $p$ liars and $q$ non-liars in the class, the number of times "liar" is mentioned is $2pq$.
Combining the given conditions, we have
$pq = 120$,
$(p-1)q = 108$ or $p(q-1) = 108$.
Solving these, we get $(p, q) = (10, 12)$ or $(12, 10)$.
Therefore, the total number of students attending today's gathering is 22.