5. The power in the kingdom of gnomes was seized by giants. The giants decided to get rid of the gnomes and told them the following: "Tomorrow we will line you up so that each of you will see those who stand after and not see those who stand before (i.e., the 1st sees everyone, the last sees no one). We will put either a black or a white hat on each of you (equally likely, each will have either a black or a white hat) and ask what color it is. Those who answer correctly will be released, and those who answer incorrectly will be executed." How many gnomes can be risked at a minimum with certain agreements before the execution, if there are p gnomes in the kingdom and p $<\infty$. Justify your answer. (12 points)

#