One man is wearing the colored hat that his friend was wearing the coloured hat which was based on the choice of the third man x weeks ago.
Now the first man knows what hat his friend was wearing x+1 weeks ago
so he knew that the second man was not wearing today meaning that the third man was wearing a certain hat.
What is the value of x?
Use your logic and deduction skills
Remember the answer is in the question
We all get stuck sometimes