5. In the expansion of $(a+b)^{n}$, there are $n+1$ different terms. Then, the expansion of $(a+b+c+d)^{21}$ has different terms.
5.2024 .
$$
\begin{array}{l}
\because(a+b+c)^{n} \\
=(a+b)^{n}+\mathrm{C}_{n}^{1}(a+b)^{n-1} \cdot c+\cdots+\mathrm{C}_{n}^{n} \cdot c^{n}
\end{array}
$$

There are $n+1$ terms, but $(a+b)^{i}$ has $i+1$ terms, $\therefore(a+b+c)^{n}$ has the number of different terms as
$$
\begin{array}{l}
\sum_{i=0}^{n}(i+1)=\frac{1}{2}(n+1)(n+2) \text { (terms). } \\
\because(a+b+c+d)^{n}=((a+b+c)+d)^{n} \\
=(a+b+c)^{n}+C_{n}^{1}(a+b+c)^{n-1} \cdot d+\cdots+d^{n},
\end{array}
$$

There are $n+1$ terms, and $(a+b+c)^{i}$ has $\frac{1}{2}(i+1)(i+2)$ different terms.
$\therefore(a+b+c+d)^{n}$ has the number of different terms as
$$
\begin{array}{l}
\sum_{i=0}^{n} \frac{1}{2}(i+1)(i+2) \\
=\sum_{i=0}^{n} \frac{1}{2}\left(i^{2}+3 i+2\right) \\
=\frac{1}{2}\left(\frac{1}{6} n(n+1)(2 n+1)+3 \times \frac{1}{2} n(n+1)+2(n+1)\right) \\
=\frac{1}{6}(n+1)(n+2)(n+3) .
\end{array}
$$

When $n=21$, the number of terms is 2024.