Making longest sequence F(N) is defined as number of digits in a number N. EXAMPLE : F(123)=3
I want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But to add a number n to my sequence its cost me F(n)·k .
If I can spend a cost up to w, and I want to make the sequence as long as possible.I want to find sequence maximum length.Input consist of w,m,k;
EXAMPLE : for w=9 m=1 k=1 the answer will be 9.

The cost of a sequence starting at $1$ and ending at $n$ is $c(n)=k\sum_{i=0}^{\lfloor \log_{10} n \rfloor} \left\{ n-(10^i-1) \right\}= k\left\{ nd(n)-\frac{10^{d(n)}-1}{9} \right\}$ where $d(n)$ is the number of digits in decimal representation of $n$. Then the maximal length is the largest $l$ such that $c(m-1+l) \le c(m-1) + w$.
Calculate $z= \left\{ (m-1)d(m-1)-\frac{10^{d(m-1)}-1}{9} \right\}+\frac{w}{k}$. Start with $d$ equal to the number of digits in $z/d(z)$ and calculate $\lfloor \frac{z+\frac{10^d-1}{9}}{d} \rfloor$. If it has $d$ digits, stop. Otherwise try the same calculation by increasing $d$ by $1$. The maximal length is $\lfloor \frac{z+\frac{10^d-1}{9}}{d} \rfloor-(m-1)$.
