5. (10 points) There are 8 children, each wearing a red hat or a blue hat. If a child sees 3 or more other children wearing red hats, they take a red balloon; otherwise, they take a blue balloon. In the end, some children have red balloons and some have blue balloons. How many children are wearing red hats? $\qquad$
【Answer】Solution: If there is 1 or 2 children wearing red hats, then all the children will take out blue balloons;
If there are 3 children wearing red hats, then the children wearing red hats will all take out blue balloons, and the children wearing blue hats will take out red balloons; this meets the requirements of the problem.

If there are 4 or more children wearing red hats, then all the children will take out red balloons; therefore, there are a total of 3 children wearing red hats.

Answer: There are a total of 3 children wearing red hats.
So the answer is: 3.