12. Let $\mathrm{f}(n)$ be the number of 0 's in the decimal representation of the positive integer $n$. For example, $f(10001123)=3$ and $f(1234567)=0$. Find the value of
$$
f(1)+f(2)+f(3)+\ldots \ldots+f(99999)
$$
12. Answer: 38889
Let $S=\{1,2,3, \ldots \ldots, 99999\}$, and $S_{i}=\{n \in S: \mathrm{f}(n)=i\}$ for $i \geq 0$. Thus,
$$
S=\mathrm{U}_{0 \leq i \leq 4} S_{i}
$$

For $0 \leq i \leq 4$, if $n \in S_{i}$, and $n$ has exactly $k$ digits in the decimal representation, then exactly we have $k-i$ digits are non-zero. Thus,
$$
\left|S_{i}\right|=\sum_{k=i+1}^{5}\binom{k-1}{i} 9^{k-i}
$$

Then, it is clear that
$$
M=\left|S_{1}\right|+2\left|S_{2}\right|+3\left|S_{3}\right|+4\left|S_{4}\right|=38889 .
$$