5. As shown in Figure 2, in
$\triangle A B C$, $M$ is the midpoint
of side
$B C$, draw $M D$
$\perp A B$ at $D$, $M E \perp$
$A C$ at $E$. If $B D=2$,
$C E=1$, and $D E / / B C$, then $A M=$ $\qquad$
5. $\sqrt{5}$.

Let $D M=x, E M=y, A D=z, A E=w$.
Since $D E / / B C$ and $B M=M C$, we have $S_{\triangle B D M}=$ $S_{\triangle C E S}$, i.e., $\frac{1}{2} \times 2 \times x=\frac{1}{2} \times 1 \times y$. Thus, $y=2 x$.
By the Pythagorean theorem, $2^{2}+x^{2}=B M^{2}=M C^{2}=1^{2}+y^{2}$.
Therefore, $3 x^{2}=3, x^{2}=1$, which means $x=1, y=2$.
By $D E / / B C$ and the Pythagorean theorem,
$$
\frac{z}{2}=\frac{w}{1}, 1^{2}+z^{2}=A M^{2}=2^{2}+w^{2} \text {. }
$$

Thus, $z=2 w, 1+4 w^{2}=4+w^{2}$.
Solving, we get $w=1, z=2$.
Therefore, $A M=\sqrt{y^{2}+w^{2}}=\sqrt{4+1}=\sqrt{5}$.