5. The number of solutions to the equation $\cos \frac{x}{4}=\cos x$ in $(0,24 \pi)$ is
5. 20.
$$
\cos \frac{x}{4}=\cos x \Rightarrow \cos \frac{x}{4}-\cos x=0 \Rightarrow 2 \sin \frac{5}{8} x \sin \frac{3 x}{8}=0 \Rightarrow x=\frac{8}{5} m \pi \text { or } \frac{8}{3} n \pi \text {, where } m \text {, }
$$
$n \in \mathbf{Z}$ The function $f(x)=\cos x-\cos \frac{x}{4}$ has a period of $8 \pi$, within $[0,8 \pi]$ the roots of $f(x)=0$ are $0, \frac{8 \pi}{5}, \frac{16 \pi}{5}, \frac{24 \pi}{5}, \frac{32 \pi}{5}, \frac{8 \pi}{3}, \frac{16 \pi}{3}$, a total of 7 roots. Therefore, in $(0,24 \pi)$ the number of distinct solutions is $3 \times 7-1=20$ (solutions).