Ten prisoners are arrested for a crime, but the jail is full and the jailer has nowhere to put them. He eventually comes up with the solution of giving them a puzzle so if they succeed they can go free but if they fail they are executed. Each prisoner is assigned a hat with a random color out of N colors. The number of hats of a given color hat is not known to the prisoners. The jailers sets the prisoners into a line, where each can see the hats in front of him but not the ones behind. Each prisoner is allowed to say only one word which must be a color name. If the color corresponds to her hat she is released, otherwise she is killed. The prisoners have one hour to formulate a plan so as to save as many of them as possible. How many prisoners can survive and what is the plan to do so? The plan must work for any positive value of N.