5. The sequence $\left\{a_{n}\right\}$ satisfies:
$$
a_{1}=2, a_{n}+a_{n+1}=1\left(n \in \mathbf{Z}_{+}\right) \text {. }
$$

Let $S_{n}$ be the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$. Then
$$
S_{2017}-2 S_{2018}+S_{2019}=
$$
$\qquad$ .
5.3.

When $n$ is even,
$$
a_{1}+a_{2}=a_{3}+a_{4}=\cdots=a_{n-1}+a_{n}=1 \text {. }
$$

Then $S_{n}=\frac{n}{2}$.
When $n$ is odd, $a_{1}=2$,
$$
a_{2}+a_{3}=a_{4}+a_{5}=\cdots=a_{n-1}+a_{n}=1 \text {. }
$$

Then $S_{n}=2+\frac{n-1}{2}=\frac{n+3}{2}$.
Therefore, $S_{2017}-2 S_{2018}+S_{2019}$
$$
=1010-2018+1011=3 \text {. }
$$