8. For a positive integer $x$, let $S(x)$ denote the sum of the digits of $x$. Then the maximum value of $S(x)-9[\lg x]$ is $\qquad$ ( $[x]$ denotes the greatest integer not exceeding the real number $x$).
8. 9 .

Let $x=\overline{a_{n} a_{n-1} \cdots a_{0}}\left(a_{0} \neq 0\right)$. Then
$$
\begin{array}{l}
10^{n} \leqslant x<10^{n+1} \\
\Rightarrow n \leqslant \lg x<n+1 \Rightarrow[\lg x]=n . \\
\text { Hence } S(x)=a_{0}+a_{1}+\cdots+a_{n} \leqslant 9(n+1) \\
=9([\lg x]+1) .
\end{array}
$$

Therefore, $S(x)-9[\lg x] \leqslant 9$.
$$
\text { Also, } S(9)-9[\lg 9]=9 \text {, then, } S(x)-9[\lg x]
$$

has a maximum value of 9.