We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.

You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)·k to add the number n to the sequence.

You can spend a cost up to w, and you want to make the sequence as long as possible. Write a program that tells sequence's maximum length.


-----Input-----

The first line contains three integers w (1 ≤ w ≤ 10^16), m (1 ≤ m ≤ 10^16), k (1 ≤ k ≤ 10^9).

Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Output-----

The first line should contain a single integer — the answer to the problem.


-----Examples-----
Input
9 1 1

Output
9

Input
77 7 7

Output
7

Input
114 5 14

Output
6

Input
1 1 2

Output
0

Difficulty: interview

Starter code:

Solutions:
import math
w,m,k=list(map(int,input().split()))

x=int("1"+("0"*len(str(m))))

h=x-m
n=len(str(m))

ans=w//(n*k)

if(ans>h):
    ans=h
    w-=h*n*k
    while(w>0):
        n+=1
        x=w//(n*k)
        if(x>=10**(n-1)*9):
            ans+=(10**(n-1))*(9)
            w-=(n*k*(10**(n-1))*(9))
        else:
            ans+=x
            break
print(ans)
    
    


def cnt(x, y):
  return y-x

w, m, k = list(map(int, input().split()))
p, d, res = 1, 0, 0
while p <= m:
  p *= 10
  d += 1
while cnt(m, p)*d*k <= w:
  w -= cnt(m, p)*d*k
  res += cnt(m, p)
  m = p
  p *= 10
  d += 1
res += w//(d*k)

print(res)


a, b, c = list(map(int, input().split()))
ans = 0
temp = len(str(b))

while a > 0:
	cnt = "1" + "0" * temp
	d = int(cnt) - b
	cur = a // (temp * c)
	a -= min(d, cur) * c * temp
	ans += min(d, cur)
	b = int(cnt)
	temp += 1
	if cur == 0:
		break
	
print(ans)


w, m, k = map(int, input().split())
L = len(str(m))
end = m
flag = False
while True:
    if w > (10 ** L - end) * k * L:
        w -= (10 ** L - end) * k * L
        end = 10 ** L
        L += 1
        #if w < L * k:
            #print(end - m)
            #flag = True
            #break
        #else:
            #w -= L * k
            #end = 10 ** L + 1
    else:
        end += w // (L * k)
        break

if not(flag):
    print(end - m)

3

def readln(): return tuple(map(int, input().split()))

w, m, k = readln()
s = 1
ans = 0
while w:
    while m >= 10 ** s:
        s += 1
    cnt = 10 ** s - m
    if cnt * s * k <= w:
        ans += cnt
        w -= cnt * s * k
        m = 10 ** s
    else:
        ans += w // (s * k)
        w = 0
print(ans)


w, m, k = map(int, input().split())
cost, num = 0, 0
ln = len(str(m))
aim = 10**ln
if (aim - m)*ln*k <= w:
    cost += (aim - m)*ln*k
    num += (aim - m)
    m = aim
    ln += 1
    while True:
        if ln*k*9*10**(ln-1)+cost <= w:
            cost += ln*k*9*10**(ln-1)
            num += 9*10**(ln-1)
            m = 10**ln
            ln += 1
        else:
            break
lastm = m
aim = 10**ln
mid, lastn = 0, 0
while aim != m+1:
    mid = m + (aim-m)//2
    if ln*k*(mid-lastm)+cost <= w:

        m = mid

    else:
        aim = mid

print(num + m - lastm)

import sys

w, m, k = map(int, input().split())

def next(n):
    a, cnt = 1, 1
    while a <= n:
        a *= 10
        cnt += 1
    return a, cnt - 1

m0 = m

while w > 0:
    M, s = next(m)
    if (M - m) * s * k >= w:
        M = (w + m * s * k) // (s * k)
        print(M - m0)
        return
    else:
        w -= (M - m) * s * k
        m = M

w,m,k=map(int,input().split())
ans=0
while w>=len(str(m))*k:
    ans+=min(w//(k*len(str(m))),10**len(str(m))-m)
    w1=w
    m1=m
    m+=min(w1//(k*len(str(m1))),10**len(str(m1))-m1)
    w-=k*len(str(m1))*min(w1//(k*len(str(m1))),10**len(str(m1))-m1)
    #print(w,m,ans)
print(ans)

(w, m, k) = (int(string) for string in input().split())
answer = 0
digitCount = len(str(m))
while w > 0:
    ceiling = 10**digitCount
    numberCountInThisLength = ceiling - m
    cost = digitCount * k * numberCountInThisLength
    if w > cost:
        w -= cost
        answer += numberCountInThisLength
        m = ceiling
        digitCount += 1
    else:
        answer += w / (k*digitCount)
        break

print('%d' % answer)


from math import log10

w,m,k = list(map(int,input().split()))
d = 0
z = int(log10(m))
zlom = 10**z
while w > 0 :
	z+=1
	zlom*=10
	c = (zlom-m)*z*k
	if c > w :
		x = w//(z*k)
		d+=x
		break
	w-=c
	d+=(zlom-m)
	m = zlom
print(d)


w,m,k=list(map(int,input().split()))
#print('w='+str(w)+' m='+str(m)+' k='+str(k))
n=m-1
l=len(str(m))
#print('l='+str(l))
while w>0:
    t=((10**l)-n-1)*l*k
    #print('t='+str(t))
    if w<=t:
        n+=w//(l*k)
        w=0
    else:
        n=10**l
        w=w-t-(l+1)*k
        l+=1
    #print('n='+str(n)+' w='+str(w))
print(n-m+1)


w, m, k = map(int, input().split())
ans = 0

while w > 0:
    l = len(str(m))
    ans += min(w / (l * k), (10 ** l - m))
    w -= k * (10 ** l - m) * l
    m = 10 ** l
print (int(ans))

w, m, k = input().split()
k = int(w) // int(k)
l, m = len(m), int(m)
s = pow(10, l)
if (s - m) * l > k: print(k // l)
else:
    k -= (s - m) * l
    l += 1
    d = 9 * s
    while d * l <= k:
        k -= d * l
        l += 1        
        s += d
        d = 9 * s
    print(s - m + k // l)

w, m, k = tuple(map(int,input().split()))
s = len(str(m))
t = m
n = 10 ** s
r = (n - t) * s * k
while w >= r:
    w -= r
    t = n
    n *= 10
    s += 1
    r = (n - t) * s * k
if w != 0:
    n //= 10
    if n < m:
        n = 0
    else: n -= m
    r = s * k
    n += w // r
else: n = n // 10 - m
print(n)

# -*- coding: utf-8 -*-
import sys

w, m, k = (int(x) for x in sys.stdin.readline().split(' '))
n = w // k

def S(x):
    i = 0
    while x:
        i += 1
        x //= 10
    return i

c = 0
l = S(m)
while True:
    num = 10 ** l - m
    if n > num * l:
        n -= num * l
        c += num
        m = 10 ** l
        l += 1
    else:
        c += n // l
        break
print(c)

def number_of_digits(n):
    if n == 0:
        return 0
    else:
        return 1 + number_of_digits(n//10)

def calc(n):
    if n <= 0:
        return 0
    d = number_of_digits(n)
    ret = 0
    for i in range(1,d):
        ret += 9*(10**(i-1))*i
    ret += (n-(10**(d-1))+1)*d

    return ret


def calc2(f,t):
    return calc(t) - calc(f-1)

def solve(w,m,k):
    lower = 0
    upper = m+w
    for i in range(100):
        mid = (lower+upper)//2
        cur = calc2(m,mid)

        if k*cur <= w:
            lower = mid
        else:
            upper = mid

    return lower - m + 1

def main():
    w,m,k = list(map(int,input().split()))
    print(solve(w,m,k))

def __starting_point():
    main()

__starting_point()

def f(x):
    digs = len(str(x))
    
    ndig = digs*(x - 10**(digs-1) + 1)
    for i in range(1, digs):
        ndig += i * 9*10**(i-1)
    return ndig

a, b, c = list(map(int, input().split(' ')))
num = a // c

need = num + f(b-1)

lo = 0
hi = 10**18

while lo < hi:
    mid = (lo + hi + 1) // 2
    if f(mid) > need:
        hi = mid - 1
    else:
        lo = mid
print(lo-b+1)


import sys

def solve():
    w,m,k, = rv()
    small, large = 0, int(1e16)
    while small < large:
        avg = (small + large + 1) // 2
        if works(avg, w, m, k): small = avg
        else: large = avg - 1
    print(small)

def works(numbers, maxcost, startnum, multiplier):
    maxnumber = numbers + startnum - 1
    res = 0
    for length in range(1, 20):
        goodoflength = max(0, maxnumber - (pow(10, length - 1) - 1))
        badoflength = max(0, startnum - (pow(10, length - 1) - 1) - 1)
        res += (goodoflength - badoflength)
    return res * multiplier <= maxcost

def rv(): return list(map(int, input().split()))
def rl(n): return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()




p=input().split()
w=int(p[0])
m=int(p[1])
a=m
cost=int(p[2])
c=0
while(m!=0):
    m=m//10
    c=c+1
sum=0
x=10**c-a
if cost*c*x>=w:
    print(w//(cost*c))
else:
    sum=sum+x
    w=w-cost*c*x
    for i in range(c+1,18):
        y=9*(10**(i-1))
        if(y*i*cost>=w):
            break
        else:
            w=w-cost*y*i
            sum=sum+y
    print(sum+w//(cost*i))
        


def s(n):
    return len(str(n))

def main():
    mode="filee"
    if mode=="file":f=open("test.txt","r")
    get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
    [w,m,k]=get()
    ans=0
    while w>= (10**s(m)-m)*s(m)*k:
        w-=(10**s(m)-m)*s(m)*k
        ans+=(10**s(m)-m)
        m=10**s(m)
    w=w//(k*(s(m)))
    ans+=(w)
    print(ans)
    
    if mode=="file":f.close()

def __starting_point():
    main()

__starting_point()

w, m, k = list(map(int, input().split()))
d, v = len(str(m)), 0
c = min(10 ** d - m, w // (k * d))
while c:
    v += c
    w -= c * k * d
    m = 10 ** d
    d += 1
    c = min(10 ** d - m, w // (k * d))
print(v)


def fhelp(a):
    s = 1
    f = 10
    res = 0
    while a >= s:
        if (a >= s and a < f):
            break
        res += len(str(s)) * k * (f - s)
        s *= 10
        f *= 10  
    res += len(str(a)) * k * (a - s + 1)
    return res

def f(a, b):
    return fhelp(b) - fhelp(a - 1)
    
w, m, k = list(map(int, input().split()))
#print(fhelp(10))
l = m - 1
r = 1000000000000000000
while (r - l > 1):
    c = (r + l) // 2
    if w >= f(m, c):
        l = c
    else:
        r = c
print(l - m + 1)


def fhelp(a):
    s = 1
    f = 10
    res = 0
    while a >= s:
        if (a >= s and a < f):
            break
        res += len(str(s)) * k * (f - s)
        s *= 10
        f *= 10  
    res += len(str(a)) * k * (a - s + 1)
    return res

def f(a, b):
    return fhelp(b) - fhelp(a - 1)
    
w, m, k = map(int, input().split())
w += fhelp(m - 1)
#print(fhelp(10))
summ = 0
power = 1
count = 9
while summ <= w:
    q = power * k * count
    if summ + q > w:
        break
    summ += q
    power += 1
    count *= 10
diff = w - summ
diff //= (power * k)
num = 10**(power - 1) + diff
print(num - m)

w, m, k = map(int, input().split())
w //= k

pre = 0
cur = 9
len = 1
saved_m = m
while m > cur:
	pre += cur * len
	m -= cur
	cur *= 10
	len += 1
pre += (m - 1) * len

w += pre

ans = 0
cur = 9
len = 1
while w > cur * len:
	w -= cur * len
	ans += cur
	cur *= 10
	len += 1
ans += w // len

print(ans - saved_m + 1)

w, m, k = map(int, input().split())


def size(a):
    return len(str(a))

def how_many(m, n):
    len1 = size(m)
    len2 = size(n)
    if len1 == len2:
        return (n - m + 1) * len1
    else:
        cnt = 0
        for len in range(len1, len2 + 1):
            if len == len1:
                cnt += (pow(10, len1) - m) * len
            elif len == len2:
                cnt += (n - pow(10, len2 - 1)) * len
            else:
                cnt += (pow(10, len) - pow(10, len - 1)) * len
        return cnt + len2

def check(n):
    return how_many(m, n) * k <= w


l = m
r = 10 ** 18
while (r - l > 1):
    n = l + (r - l) // 2
    if check(n):
        l = n
    else:
        r = n
if l != m:
    print(l - m + 1)
else:
    print(int(check(m)))