Hats in 2015Logic Level 2
There are 2015 people standing in a line. Each person is given one hat to wear. A hat has one of 2015 possible colors, and it is possible to distinguish from these 2015 colors. Duplicate hat colors are possible.
A person cannot see his own hat color or the hats of the people behind him, but he can see the colors of the hats of all the people in front of him. (Note that the person at the back of the line can see everyone else's hats and the person in front can see no one's hats.)
Starting from the back of the line and moving to the front, each person is asked to guess the color of their own hat. If a person guesses his or her hat color correctly, the person gets to keep the hat. If not, he or she has to give up the hat.
The 2015 people are allowed to devise a strategy before they form the line. They agree on a strategy that maximizes the number \(a\) of hats guaranteed to be kept. What is \(a\)?