Since A is silent, A must see a red and a green hat. B can see C, so whatever colour hat C has on, B knows to say the other colour.