Aiming for the wrong answer seems to be the way to go.
Count how many of either color, the only hat you dont know is yours, so be off count by two
so lets say 3R and 2B and you 1? so just say 5R and 1B or 4B and 2R
I think the only way it doesn't work if there's just you and one other person