Three prisoners get a chance to get a free out of jail card but they have to play a game. 
They see 5 hats, 2 white ones and 3 black ones. Each prisoner gets told that they get one of the 5 hats but can't see their own hat
They are placed in such a way that each prisoner can see the hat of the other two, but not their own. 
They are not allowed to communicate or give signs. 
The guards give them the 3 black hats.
If a prisoner says the wrong color, they all stay in jail.
After half an hour all 3 say, they have a black hat. 
How did they know?