5. The number $S$ is the result of the following sum:

$$
1+10+19+28+37+\cdots+10^{2013} .
$$

If the number $S$ is written out, how many times does the digit ' 5 ' appear in the result?
5. To determine the idea, we first calculate the number of fives in the result $s$ of the sum $1+$ $10+19+\cdots+100000$. First, note that each term in the sum is a multiple of nine plus 1:

$$
s=1+(1+9)+(1+2 \cdot 9)+\cdots+(1+11111 \cdot 9) .
$$

The number of terms in the sum is $11111+1=11112$ and the average value of a term is $\frac{1+100000}{2}$. It follows that $s=11112 \cdot \frac{100001}{2}=\frac{11112}{2} \cdot 100001$.

Since $\frac{11112}{2}=\frac{5 \cdot 11112}{5 \cdot 2}=\frac{55560}{10}=5556$, we find that $s=5556+555600000=555605556$. The number of fives in this case is equal to 6.

We now solve the actual problem. Note that $10^{2013}=1+9 \cdot 11 \ldots 1$ (2013 ones). For convenience, let $n=11 \ldots 1$ be the number consisting of 2013 ones. We see that the sum

$$
S=1+(1+9)+(1+2 \cdot 9)+\cdots+(1+n \cdot 9)
$$

has exactly $n+1$ terms, with an average value of $\frac{1+10^{1023}}{2}$. Thus, $S=\frac{n+1}{2} \cdot\left(1+10^{2013}\right)$.

Evaluating the fraction $\frac{n+1}{2}$ gives:

$$
\frac{n+1}{2}=\frac{5 n+5}{10}=\frac{555 \ldots 560}{10}=555 \ldots 56
$$

a number with 2011 fives followed by a 6. Since the last 2013 digits of the number $10^{2013} \cdot \frac{n+1}{2}$ are all zeros, there is no 'overlap' between the non-zero digits of $\frac{n+1}{2}$ and $10^{2013} \cdot \frac{n+1}{2}$. We now find that

$$
\begin{aligned}
S & =\frac{n+1}{2} \cdot\left(1+10^{2013}\right) \\
& =\frac{n+1}{2}+10^{2013} \cdot \frac{n+1}{2} \\
& =55 \ldots 56055 \ldots 56 .
\end{aligned}
$$

Thus, $S$ is a number that contains exactly $2011+2011=4022$ fives.