A teacher noticed a strange distribution of marks in the exam. There were only three distinct scores: $6, 8,$ and $20$. The mode of the distribution was $8$. The sum of the scores of all the students was $504$. The number of students in the most populated category was equal to the sum of the number of students with lowest score and twice the number of students with the highest score. The total number of students in the class was: