4. (10 points) Among the natural numbers less than 1000, there are $\qquad$ numbers whose digits consist of at most two different digits.
【Analysis】We can first find the number of numbers that have three identical digits, and then subtract this from the total number 1000 to get the number of numbers that "have at most two different digits" in their composition.

【Solution】Solution: According to the analysis, among the natural numbers less than 1000, the numbers with three different digits are: \(9 \times 9 \times 8 = 648\),

Thus, the numbers with at most two different digits are: \(1000 - 648 = 352\).
Therefore, the answer is: 352.
From the above table, we can derive:
$$
\begin{array}{l}
a_{4}=a_{28}=9, S\left(a_{4}\right)=S\left(a_{28}\right)=9 ; \\
a_{5}=a_{29}=14, S\left(a_{5}\right)=S\left(a_{29}\right)=5 ;
\end{array}
$$

We can observe the pattern: when \(i \geqslant 4\), \(a_{i}=a_{i+24}, S\left(a_{i}\right)=S\left(a_{i+24}\right)\),
$$
2017-3=2014,2014 \div 24=83 \cdots 22 \text {, }
$$

Therefore: \(a_{2017}=a_{3+22}=a_{25}=10\).