2. (2 points) In a class, 10 people gathered, each of whom is either a knight, who always tells the truth, or a liar, who always lies. Each of them was asked to first name the number of knights in the room, and then the number of liars. It turned out that each number from 0 to 9 was named exactly twice. How many knights could there be in the class? Find all possible variants and prove that there are no others.
Answer: from 0 to 2.

Solution: Since knights give the same answer to all questions, there cannot be more of them than the maximum number of identical answers, i.e., 2. It is easy to construct examples of all cases. If there are two knights, they tell the truth, and each liar chooses a number other than 2 and 8, and mentions the chosen number both times. If there is one knight, the eight liars each name a different number except 1 and 9, and the ninth liar names 9 and 1 in the wrong order. If there are no knights, everyone names even numbers when asked about the number of knights, and odd numbers when asked about the number of liars.