8. Arrange all positive integers whose sum of digits is 10 in ascending order to form the sequence $\left\{a_{n}\right\}$. If $a_{n}=2017$, then $n=$ $\qquad$ .
8. 120.

It is easy to know that there are 9 two-digit numbers $\overline{a b}$ whose digits sum to 10.
For three-digit numbers $\overline{a b c}$ whose digits sum to 10, the first digit $a$ can take any value in $\{1,2, \cdots, 9\}$. Once $a$ is determined, $b$ can take any value in $\{0,1, \cdots, 10-a\}$, which gives $11-a$ possible values. Once $a$ and $b$ are determined, the value of $c$ is uniquely determined. Therefore, the number of three-digit numbers is $\sum_{a=1}^{9}(11-a)=54$.

For four-digit numbers $\overline{1 a b c}$ where $a+b+c=9$, the number of non-negative integer solutions $(a, b, c)$ is $\mathrm{C}_{11}^{2}=55$; there are two four-digit numbers starting with 2, which are 2008 and 2017.

Thus, in $\{1,2, \cdots, 2017\}$, the number of numbers that satisfy the condition is $9+54+55+2=120$.