Problem:
A guard proposes the following game to the prisoners. All of them will be brought out into the courtyard, where each of them will have placed on his head a hat of one of 5 possible colors. The guard will then line them up in a row so that each prisoner sees all the hats except his own, and will ask the first prisoner in the row whether he knows the color of his own hat. The prisoner answers aloud "yes" or "no". If he answers "no", he will be immediately locked up in solitary confinement. If he answers "yes", the guard will ask him what color his hat is, to which the prisoner must answer in such a way that the other prisoners cannot hear the answer. If the answer is wrong, that prisoner will be immediately locked up in solitary confinement in front of everyone, and if the answer is correct, that prisoner will be immediately released in front of everyone. The guard then approaches the next prisoner in line and repeats the same procedure, and so on until the last prisoner. The prisoners have the opportunity to devise a strategy before the game begins, but once the game starts, no communication among the prisoners is allowed. If there are 2015 prisoners in the prison, what is the maximum number of prisoners who are guaranteed to be freed if the prisoners use an optimal strategy?