B2. The integer $N$ consists of 2009 nines written in sequence. A computer calculates $N^{3}=(99999 \ldots 99999)^{3}$. How many nines does the written-out number $N^{3}$ contain in total?
B2. The integer $N$ consists of 2009 nines written consecutively. A computer calculates $N^{3}=$ $(99999 \ldots 99999)^{3}$. How many nines does the written-out number $N^{3}$ contain in total? 4017

$\underbrace{99999 \ldots 99999}_{2009 \times}$

Solution $9^{3}=729 ; 99^{3}=970299 ; 999^{3}=997002999$. It appears that in general, the cube of the number $n$ consisting of $k$ nines looks like this: first $k-1$ nines; then a 7; then $k-1$ zeros; then a 2; and finally $k$ nines. To prove this, we write $n$ as $10^{k}-1$. Indeed: $\left(10^{k}-1\right)^{3}=10^{3 k}-3 \cdot 10^{2 k}+3 \cdot 10^{k}-1=10^{2 k}\left(10^{k}-3\right)+\left(3 \cdot 10^{k}-1\right)$. The number $10^{k}-3$ can be written as $999 \ldots 997$ with $k-1$ nines. Multiplied by $10^{2 k}$, this results in a number with $2 k$ zeros at the end. When we add $3 \cdot 10^{k}-1$ to this, the last $k+1$ zeros are replaced by $2999 \ldots 999$ with $k$ nines. In total, it thus contains $(k-1)+k$ nines; for $k=2009$, there are 4017.