There are $12$ prisoners named $A,B,C,D,E,F,G,H,I,J,K$ and $L$ and each of them was given a hat with the number $0,1,2,3$ or $4$ on it. They cannot see what is on their own hat but can see what is on the other $11$ prisoners' hats.
The guard calls them forward in alphabetical order and asks them to whisper in his ear what number they think is on their hat. If they are correct they are allowed to leave otherwise they get executed.
Before the prisoners are given hats they are allowed to devise an optimum strategy so that the most prisoners leave with their life. Once hats are given no communication is allowed between the prisoners (including any sort of secret code).
What is the optimum strategy and how many prisoners can survive?