In a classroom, there are 24 students. If 1/3 of the students are wearing glasses, and out of those wearing glasses, 1/2 are also wearing hats, how many students are wearing both glasses and hats? Let's think step by step and output the final answer within \boxed{}.
user