Three. (25 points) Given $x_{1}, x_{2}, \cdots, x_{2021}$ take values of 1 or $-\mathrm{i}$, let
$$
\begin{aligned}
S= & x_{1} x_{2} x_{3}+x_{2} x_{3} x_{4}+\cdots+x_{2019} x_{2020} x_{2021}+ \\
& x_{2020} x_{2021} x_{1}+x_{2021} x_{1} x_{2} .
\end{aligned}
$$

Find the smallest non-negative value that $S$ can take.