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: MEDIUM_HARD

Solutions:
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)


def findten(x):
	ans = 1
	while ans <= x:
		ans *= 10
	return ans

def s(x):
	ans = 0
	while x:
		ans += 1
		x //= 10
	return ans
(w, m, k) = (int(i) for i in input().split())
ans = 0
p = findten(m)
while w > 0:
	temp = s(m) * k * (p - m)
	if w - temp >= 0:
		ans += p - m
		m = p
		p *= 10
		w -= temp
	else:
		t = w // (s(m) * k)
		ans += t
		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)


(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 math
z = input().split()
w = int(z[0])
m = int(z[1])
k = int(z[2])
digs = int(math.log10(m)) + 1
upper = int('9' * digs)
ans = 0
while w > 0:
	if (upper - m + 1) * digs * k <= w:
		w = w - (upper - m + 1) * digs * k
		ans += upper - m + 1
		digs += 1
		m = int('1' + '0' * (digs - 1))
		upper = int('9' * digs)
	else:
		ans += int(w / (k * digs))
		break
print(ans)


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)


def cnt(x, y):
	return y - x
(w, m, k) = 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
(lo, hi) = (m, p)
while hi - lo > 1:
	mid = (lo + hi) // 2
	if cnt(m, mid) * d * k <= w:
		lo = mid
	else:
		hi = mid
res += cnt(m, lo)
print(res)


lst = input().split()
lst = [int(x) for x in lst]
(w, m, k) = (lst[0], lst[1], lst[2])
idx = 10
ans = 0
start = 1
while idx <= m:
	start += 1
	idx *= 10
while w:
	tmpc = start * (idx - m) * k
	if tmpc < w:
		ans += idx - m
		w -= tmpc
		m = idx
		idx *= 10
		start += 1
	else:
		ans += w // (start * k)
		break
print(ans)


(w, m, k) = list(map(int, input().split()))
z = a = 10 ** len(str(m)) - m
if a * len(str(m)) * k >= w:
	print(w // (len(str(m)) * k))
else:
	w -= a * len(str(m)) * k
	c = len(str(m)) + 1
	while w > 0:
		a = 9 * 10 ** (c - 1)
		if a * c * k >= w:
			print(w // (c * k) + z)
			break
		w -= a * c * k
		z += a
		c += 1


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


(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)))


pow10 = [10 ** i for i in range(20)]
(w, m, k) = map(int, input().split())
x = 1
while m > pow10[x]:
	x += 1
if (pow10[x] - m) * x * k >= w:
	print(w // (x * k))
	exit()
cur = (pow10[x] - m) * x * k
tmp = pow10[x] - m
x += 1
while cur + 9 * pow10[x - 1] * x * k <= w:
	cur += 9 * pow10[x - 1] * x * k
	tmp += 9 * pow10[x - 1]
	x += 1
print(tmp + (w - cur) // (x * k))


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

def erc(x):
	an = 0
	for i in range(x):
		an = an * 10 + 9
	return an

def s(x):
	y = 0
	while x > 0:
		y += 1
		x //= 10
	return y
cnt = 0
for i in range(s(m), 30):
	cnt += min(erc(i) - m + 1, w // (i * k))
	if erc(i) - m + 1 >= w / (i * k):
		w -= min(erc(i) - m + 1, w // (i * k)) * k * i
		break
	w -= min(erc(i) - m + 1, w // (i * k)) * k * i
	m = 1
	for j in range(i):
		m = m * 10
print(int(cnt))


import math
(w, m, k) = 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 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()))
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)


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

def f(x):
	p = 1
	njir = 1
	lol = 0
	while 10 * p <= x:
		lol = lol + 9 * njir * p
		njir += 1
		p = p * 10
	return (lol + njir * (x - p + 1)) * k
lo = 1
hi = 1
ans = 0
while len(str(hi)) <= 30:
	hi = hi * 10
while lo <= hi:
	mid = (lo + hi) // 2
	if f(mid) <= w + f(m - 1):
		ans = mid
		lo = mid + 1
	else:
		hi = mid - 1
print(ans - m + 1)


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)


(w, m, k) = map(int, input().split())
ten = []
power = []
ten.append(0)
power.append(0)
ten.append(1)
power.append(9)
for x in range(1, 30):
	ten.append(ten[len(ten) - 1] * 10)
	power.append(power[len(power) - 1] * 10 + 9)
cnt = 0
foo = m
while foo > 0:
	cnt = cnt + 1
	foo = foo // 10
ini = m
end = power[cnt]
cost = 0
cl = 0
for x in range(cnt, 20):
	lenght = end - ini + 1
	cl += lenght
	nc = lenght * x * k
	cost += nc
	if cost > w:
		resp = w / (x * k)
		cost -= nc
		cost += resp * x * k
		cl -= lenght
		cl += resp
		break
	ini = ten[x + 1]
	end = power[x + 1]
	w -= nc
print(int(cl))


(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))


import math

def digitos(x):
	contador = 0
	while x > 0:
		x //= 10
		contador += 1
	return contador

def Secuencia(input):
	secuencia = 0
	s = [int(x) for x in input.split(' ')]
	w = s[0]
	m = s[1]
	k = s[2]
	contadorBase = 10 ** digitos(m)
	want = -1
	while want != w:
		want = w
		sobrantes = contadorBase - m
		costo = digitos(m) * k
		if w - sobrantes * costo >= 0:
			w -= sobrantes * costo
			secuencia += sobrantes
			m += sobrantes
			contadorBase *= 10
	while w >= 0:
		costo = digitos(m) * k
		puedoComprar = w // costo
		w -= puedoComprar * costo
		secuencia += puedoComprar
		m += puedoComprar
		if w - digitos(m) * k < 0:
			break
	return secuencia

def main():
	inp = input()
	res = Secuencia(inp)
	print(res)
main()


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) = list(map(int, input().split()))
ans = 0
c = 0
n = 0
while 10 ** n <= m:
	n += 1
if (10 ** n - m) * n * k >= w:
	print(w // (n * k))
	exit()
else:
	c += (10 ** n - m) * n * k
	ans += 10 ** n - m
n += 1
while c + 10 ** (n - 1) * 9 * n * k <= w:
	c += 10 ** (n - 1) * 9 * n * k
	ans += 10 ** (n - 1) * 9
	n += 1
ans += (w - c) // (n * k)
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
	else:
		end += w // (L * k)
		break
if not flag:
	print(end - m)


(have, start, k) = map(int, input().split())
ans = 0
while have > 0:
	length = len(str(start))
	howMany = 10 ** length - start
	cost = k * howMany * length
	if cost <= have:
		ans += howMany
		have -= cost
		start = 10 ** length
	else:
		ans += max(0, have // (k * length))
		have = 0
print(ans)


import sys

def solve():
	(w, m, k) = rv()
	(small, large) = (0, int(1e+16))
	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 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()


from math import ceil

def log10(n):
	k = 0
	while 10 ** k <= n:
		k += 1
	return k
(w, m, k) = map(int, input().split())
d = 0
s = 0
n = m
while n:
	n //= 10
	d += 1
while True:
	r = log10(m)
	p = 10 ** r - m
	p *= d * k
	if w >= p:
		w -= p
		s += p // (d * k)
		m = 10 ** r
		d += 1
	else:
		s += w // (d * k)
		break
print(s)


from math import *
(w, m, k) = list(map(int, input().split()))
cnt = 0
add = 9 * 10 ** (-1) if m < 10 else 0
for i in range(int(log10(m)), int(10000000000.0)):
	v = (9 * 10 ** i - (m - 1 - 9 * 10 ** (i - 1) + add if i == int(log10(m)) else 0)) * (i + 1) * k
	if w - v < 0:
		cnt += w // ((i + 1) * k)
		break
	w -= v
	cnt += v // (k * (i + 1))
print(int(cnt))


read = lambda : tuple(map(int, input().split()))
(w, m, k) = read()
l = [10 ** v - 1 for v in range(64)]
cv = m
s = lambda v: len(str(v)) * k
cd = 0
ln = 0
for lv in l:
	if cv <= lv:
		d = min(w, (lv - cv + 1) * s(cv)) // s(cv)
		w -= d * s(cv)
		ln += d
		cv = lv + 1
	if w <= 0:
		break
print(ln)


(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)


(w, m, k) = map(int, input().split())
cur = len(str(m))
g = 9
base = 1
g = g * 10 ** (cur - 1)
base = base * 10 ** (cur - 1)
gg = g - (m - base)
ans = 0
while w:
	if w > cur * gg * k:
		w -= cur * gg * k
		ans += gg
		cur += 1
		gg = g * 10
		g *= 10
	else:
		ans += w // (cur * k)
		break
print(ans)


(w, m, k) = map(int, input().split())
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) = 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)


def sum(k):
	ret = 0
	pw = 10
	len = 1
	while 1 == 1:
		cur = min(pw - 1, k)
		prev = pw // 10
		ret += (cur - prev + 1) * len
		if pw - 1 >= k:
			break
		len += 1
		pw *= 10
	return ret
(w, m, k) = map(int, input().split())
lo = 0
hi = int(1e+18)
while hi - lo > 1:
	md = (lo + hi) // 2
	c = sum(m + md - 1) - sum(m - 1)
	if c * k <= w:
		lo = md
	else:
		hi = md
print(lo)


(w, m, k) = list(map(int, input().split()))
ans = 0
c = 0
n = 0
while 10 ** n <= m:
	n += 1
while c + (10 ** n - m) * n * k <= w:
	c += (10 ** n - m) * n * k
	ans += 10 ** n - m
	m = 10 ** n
	n += 1
ans += (w - c) // (n * k)
print(ans)


(w, m, k) = input().split()
w = int(w)
m = int(m)
k = int(k)
ans = 0
clen = len(str(m))
while w > 0:
	mx = pow(10, clen) - 1
	diff = mx - m + 1
	cost = clen * diff * k
	if w >= cost:
		w -= cost
		ans += diff
	else:
		diff = w // clen
		diff = diff // k
		ans += diff
		break
	clen += 1
	m = mx + 1
print(ans)


a = input().split()
l = len(a[1])
p = int(a[1])
d = 10 ** l
m = int(a[2])
w = int(a[0])
c = 0
while l * m <= w:
	r = min(int(w / (l * m)), d - p)
	c += r
	w -= r * l * m
	p = d
	d *= 10
	l += 1
print(c)


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


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 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()


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)
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)


def log10_(a):
	ans = 0
	while a // 10:
		ans += 1
		a = a // 10
	return ans

def pow10(a):
	ans = 1
	for i in range(a):
		ans *= 10
	return ans
(w, m, k) = [int(x) for x in input().split()]
ans = 0
costo = k * (log10_(m) + 1)
for i in range(log10_(m) + 1, 18):
	if (pow10(i) - m) * costo > w:
		ans += w // costo
		break
	w -= (pow10(i) - m) * costo
	ans += pow10(i) - m
	costo += k
	m = pow10(i)
print(ans)


pow10 = [1 for i in range(19)]
for i in range(1, 19):
	pow10[i] = pow10[i - 1] * 10
(w, m, k) = map(int, input().split())
x = 1
while m > pow10[x]:
	x += 1
if (pow10[x] - m) * x * k >= w:
	print(int(w / (x * k)))
else:
	cur = (pow10[x] - m) * x * k
	temp = pow10[x] - m
	while True:
		x += 1
		if cur + 9 * pow10[x - 1] * x * k > w:
			break
		cur += 9 * pow10[x - 1] * x * k
		temp += 9 * pow10[x - 1]
	print(temp + int((w - cur) / (x * k)))


def s():
	[w, m, k] = list(map(int, input().split()))
	r = 0
	c = 1
	while c > 0:
		l = len(str(m))
		c = min(w // (l * k), 10 ** l - m)
		m += c
		w -= c * l * k
		r += c
	print(r)
s()


(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(ans)


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 nxt_num(n):
	return 10 ** len(str(n))

class CodeforcesTask373BSolution:

	def __init__(self):
		self.result = ''
		self.w_m_k = []

	def read_input(self):
		self.w_m_k = [int(x) for x in input().split(' ')]

	def process_task(self):
		k = self.w_m_k[2]
		budget = self.w_m_k[0]
		pos = self.w_m_k[1]
		length = 0
		while True:
			if (nxt_num(pos) - pos) * len(str(pos)) * k <= budget:
				budget -= (nxt_num(pos) - pos) * len(str(pos)) * k
				length += nxt_num(pos) - pos
				pos = nxt_num(pos)
			else:
				fin = budget // (len(str(pos)) * k)
				budget -= fin * (len(str(pos)) * k)
				length += fin
				break
		self.result = str(length)

	def get_result(self):
		return self.result
Solution = CodeforcesTask373BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(w, m, k) = list(map(int, list(input().split())))
w = w // k
logm = len(str(m))
nextpow = 10 ** logm - m
total = 0
while w >= logm * nextpow:
	total += nextpow
	w -= logm * nextpow
	nextpow = 9 * 10 ** logm
	logm += 1
total += w // logm
print(total)


(w, m, k) = map(int, input().split())
z = m
dig = 0
while z > 0:
	dig += 1
	z = z // 10
if dig * k > w:
	print(0)
	exit(0)
lo = m - 1
hi = w + m + 5
while lo + 1 < hi:
	mid = (lo + hi) // 2
	(cost, t, d) = (0, 0, 0)
	x = mid
	while x > 0:
		x = x // 10
		d += 1
	if d == dig:
		cost = (mid - m + 1) * d * k
	else:
		t = pow(10, dig)
		last = m
		c = dig
		while t <= mid:
			cost += (t - last) * c * k
			c += 1
			last = t
			t = t * 10
		t = t // 10
		cost += (mid - t + 1) * c * k
	if cost <= w:
		lo = mid
	else:
		hi = mid
print(lo - m + 1)


(a, b, c) = 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)


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

def last(mx, m, k):
	return mx - (mx - m) % k

def quanto(m, st):
	mx = int(10 ** st)
	cl = mx - m
	m = mx
	return (cl, m)
(w, m, k) = map(int, input().split(' '))
d = 0
while 1:
	l = dec_len(m)
	(cl, nm) = quanto(m, l)
	if w > cl * k * l:
		w -= cl * k * l
		d += cl
	else:
		cl = w // (k * l)
		d += cl
		break
	m = nm
print(d)