Can you solve the hat riddle?

Veritasium

Open page