Example: 223 red flags and 4 blue flags are arranged in a row, where the 3 red flags are not all together and the 4 blue flags are not all together. How many such arrangements are there?

Translate the above text into English, please keep the original text's line breaks and format, and output the translation result directly.
Let $S$ be the set of all flag arrangements, $A_{1}$ be the set of arrangements where all 3 red flags are together, and $A_{2}$ be the set of arrangements where all 4 blue flags are together. Thus,
$$
|S|=\frac{7!}{3!\cdot 4!}=35,\left|A_{1}\right|=\frac{5!}{1!\cdot 4!}=5,\left|A_{2}\right|=\frac{4!}{3!\cdot 1!}=4,
$$

By the principle of inclusion-exclusion, the number of desired arrangements is
$$
\begin{aligned}
\left|\bar{A}_{1} \cap \bar{A}_{2}\right| & =|S|-\left|A_{1}\right|-\left|A_{2}\right|+\left|A_{1} \cap A_{2}\right| \\
& =35-5-4+2=28 .
\end{aligned}
$$