5. (10 points) In a sheep pen, there are several chickens and sheep. If half of the chickens are driven out of the sheep pen, then the total number of legs of the remaining chickens and sheep in the pen is exactly twice the total number of legs of the chickens in the pen; If 4 sheep are driven out of the sheep pen, then the total number of legs of the remaining chickens and sheep in the pen is exactly four times the total number of legs of the sheep in the pen. How many sheep are there in total? $\qquad$
【Solution】Solution: According to the problem, half of the chickens were driven out of the sheep pen, and the total number of legs of the remaining chickens and sheep in the pen is exactly twice the total number of legs of the chickens in the pen. This means the number of chickens is twice the number of sheep. Let's assume there were originally $x$ sheep, then after half of the chickens were driven out, there are $2x$ chickens left in the pen.
$$
\begin{array}{l}
(x-4) \times 4 \times(4-1)=2 x \times 2 \\
(x-4) \times 4 \times 3=4 x \\
12 x-48=4 x \\
12 x-4 x=48 \\
8 x=48 \\
x=6 \\
6+4=10 \text { (sheep) }
\end{array}
$$

Answer: There are a total of 10 sheep.
Therefore, the answer is: 10.