Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different special properties, he wants to know how rare (or not rare) they are — in fact, he needs to calculate the quantity of really big numbers that are not greater than n.

Ivan tried to do the calculations himself, but soon realized that it's too difficult for him. So he asked you to help him in calculations.


-----Input-----

The first (and the only) line contains two integers n and s (1 ≤ n, s ≤ 10^18).


-----Output-----

Print one integer — the quantity of really big numbers that are not greater than n.


-----Examples-----
Input
12 1

Output
3

Input
25 20

Output
0

Input
10 9

Output
1



-----Note-----

In the first example numbers 10, 11 and 12 are really big.

In the second example there are no really big numbers that are not greater than 25 (in fact, the first really big number is 30: 30 - 3 ≥ 20).

In the third example 10 is the only really big number (10 - 1 ≥ 9).

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Sorting

Mathematics

Complete search


Solutions:
class ReallyBigNumbers:

	def __init__(self, n, s):
		self.n = n
		self.s = s
		self.binarySearch()

	def binarySearch(self):
		l = self.s
		h = 10000000000000000000
		while l < h:
			mid = (h + l) // 2
			if self.isReallyBig(mid):
				h = mid
			else:
				l = mid + 1
		self.x = int(l)

	def isReallyBig(self, v):
		cp = v
		add = 0
		while v > 0:
			add += v % 10
			v //= 10
		return cp - add >= self.s

	def show(self):
		if self.x <= self.n:
			print(str(self.n - self.x + 1))
		else:
			print(0)
(n, s) = list(map(int, input().split()))
rbg = ReallyBigNumbers(n, s)
rbg.show()


(n, s) = map(int, input().split())
(lo, hi) = (s, n)
ans = n + 1
while lo <= hi:
	mid = (lo + hi) // 2
	z = sum(map(int, str(mid)))
	if mid >= s + z:
		ans = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(n - ans + 1)


(n, s) = map(int, input().split())
ans = 0
p = s
for i in range(163):
	p = s + i
	if p > n:
		break
	if p >= s + sum(map(int, str(p))):
		ans += 1
if p <= n:
	ans += n - p
print(ans)


(n, s) = [int(i) for i in input().split()]
print(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))


def sd(n):
	acc = 0
	while n:
		acc += n % 10
		n //= 10
	return acc

def rb(n, s):
	return n - sd(n) >= s
(n, s) = map(int, input().split(' '))
left = 1
right = n + 1
while left != right:
	mid = (left + right) // 2
	if rb(mid, s):
		right = mid
	else:
		left = mid + 1
print(n - left + 1)


(n, s) = map(int, input().split())
(a, b, c) = (0, n + 1, 0)
while a < b:
	c = (a + b) // 2
	if c - sum([int(x) for x in str(c)]) < s:
		a = c + 1
	else:
		b = c
print(n - b + 1)


def main():
	(n, s) = map(int, input().split())
	a = BS(1, n, s)
	print(n - a + 1)

def BS(f, l, d):
	if f > l:
		return f
	mi = (f + l) // 2
	if mi - sum([int(j) for j in str(mi)]) >= d:
		return BS(f, mi - 1, d)
	else:
		return BS(mi + 1, l, d)
main()


(n, s) = [int(x) for x in input().split()]

def check(x):
	y = list(str(x))
	ans = x
	for i in y:
		ans -= int(i)
	if ans >= s:
		return True
	return False
ans = 0
l = 1
r = n
while l <= r:
	m = (l + r) // 2
	if check(m):
		ans = n - m + 1
		r = m - 1
	else:
		l = m + 1
print(ans)


def case(mid):
	res = 0
	for (k, x) in enumerate(str(mid)):
		res += int(x)
	return res
(n, s) = map(int, input().split())
(i, j) = (0, n)
while i + 1 < j:
	mid = (i + j) // 2
	result = case(mid)
	if mid - case(mid) < s:
		i = mid
	else:
		j = mid
if i - case(i) >= s:
	print(n - i + 1)
elif j == n:
	if j - case(j) >= s:
		print(1)
	else:
		print(0)
else:
	print(n - j + 1)


(n, s) = map(int, input().split())

def really_big(ni, s):
	dig_sum = sum(list(map(int, list(str(ni)))))
	return ni - dig_sum >= s
cont = 0
for i in range(s, n + 1):
	if really_big(i, s):
		cont = n - i + 1
		break
print(cont)


f = lambda x: x - sum((int(i) for i in str(x))) >= s
(n, s) = map(int, input().split())
l = 0
r = n + 1
while r - l > 1:
	m = l + r >> 1
	if f(m):
		r = m
	else:
		l = m
print(n - r + 1)


(n, k) = [int(x) for x in input().strip().split(' ')]
(s, e) = (1, n + 1)
while s < e:
	mid = (s + e) // 2
	if mid - sum([int(x) for x in str(mid)]) < k:
		s = mid + 1
	else:
		e = mid
print(n - s + 1)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def sod(n):
	s = 0
	while n:
		s += n % 10
		n //= 10
	return s

def solve():
	(n, s) = mi()

	def fun(mid):
		return mid - sod(mid) >= s
	l = 0
	r = n
	ans = -1
	while l <= r:
		m = l + (r - l) // 2
		if fun(m):
			ans = m
			r = m - 1
		else:
			l = m + 1
	if ans == -1:
		ans = n + 1
	print(n - ans + 1)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


(n, s) = map(int, input().split())
l = n + 1
for i in range(s, min(s + 1000000, n) + 1, 1):
	cur = sum([int(j) for j in str(i)])
	if i - cur >= s:
		l = i
		break
print(n - l + 1)


(n, s) = map(int, input().split())

def diff(m):
	return m - sum([int(k) for k in list(str(m))])

def digit_safe(k):
	r = len(list(str(k)))
	return toint(['1'] + ['0'] * (r - 1))
a = list(str(n))
b = list(str(s))
d = int(a[0])

def toint(l):
	return int(''.join(l))
res = 0
for i in range(d):
	z = toint([str(i)] + ['0' for _ in range(len(a) - 1)])
	z1 = toint([str(i + 1)] + ['0' for _ in range(len(a) - 1)])
	count = diff(z)
	while z < z1 and count < s:
		z += digit_safe(s - count)
		count = diff(z)
	if z <= z1:
		res += z1 - z
z = toint([str(d)] + ['0' for _ in range(len(a) - 1)])
z1 = n + 1
count = diff(z)
while z < z1 and count < s:
	z += digit_safe(s - count)
	count = diff(z)
if z <= z1:
	res += z1 - z
print(res)


def really_big(x):
	sum_digit = 0
	digits = x
	while digits > 0:
		sum_digit += digits % 10
		digits = digits // 10
	if x - sum_digit >= s:
		return True
	return False

def solve():
	left = 1
	right = n
	ans = 0
	while left <= right:
		mid = (left + right) // 2
		if really_big(mid):
			right = mid - 1
			ans = n - mid + 1
		else:
			left = mid + 1
	return ans
(n, s) = map(int, input().split())
print(solve())


def getSum(n):
	ans = 0
	while n > 0:
		ans = ans + n % 10
		n = n // 10
	return ans
(n, s) = (int(x) for x in input().split(' '))
(l, h) = (1, n)
while l < h:
	mid = l + (h - l >> 1)
	sum = int(getSum(mid))
	if mid - sum >= s:
		h = mid
	else:
		l = mid + 1
sum = int(getSum(l))
if l - sum >= s:
	print(n - l + 1)
else:
	print(0)


(n, s) = list(map(int, input().split(' ')))

def sumd(d):
	sd = 0
	while d != 0:
		sd += d % 10
		d //= 10
	return sd
(st, ed) = (1, n)
r = 0
while True:
	if st == ed:
		r = st
		break
	x = (st + ed) // 2
	if x - sumd(x) < s:
		st = x + 1
	else:
		ed = x
if r - sumd(r) >= s:
	print(n - r + 1)
else:
	print(0)


(n, s) = [int(x) for x in input().split()]

def is_really_big(n):
	digit_sum = sum([int(x) for x in str(n)])
	return n - digit_sum >= s
import sys
if is_really_big(n) == False:
	print(0)
	sys.exit()
lower_bound = 1
upper_bound = n
a = 0
import pdb
while upper_bound - lower_bound > 1:
	a = (lower_bound + upper_bound) // 2
	if is_really_big(a):
		upper_bound = a
	else:
		lower_bound = a
print(n - lower_bound)


def sum_digits(n):
	s = 0
	while n:
		s += n % 10
		n //= 10
	return s

def binsearch(l, r, elem):
	n = r
	medium = (l + r) // 2
	s = medium - sum_digits(medium)
	s1 = medium - 1 - sum_digits(medium - 1)
	s2 = medium + 1 - sum_digits(medium + 1)
	while not (s2 >= elem and s < elem):
		if s < elem:
			l = medium
		elif s >= elem:
			r = medium
		k = medium
		medium = (l + r) // 2
		if k == medium:
			break
		s = medium - sum_digits(medium)
		s2 = medium + 1 - sum_digits(medium + 1)
	s1 = medium - 1 - sum_digits(medium - 1)
	if s >= elem and s1 < elem:
		return medium
	elif s2 >= elem and s < elem:
		return medium + 1
	else:
		return n + 1
(n, s) = list(map(int, input().split()))
if n == s:
	print(0)
else:
	y = binsearch(0, n, s)
	print(n - y + 1)


(n, s) = map(int, input().split())

def digs(k):
	r = k
	while k:
		r -= k % 10
		k //= 10
	return r
x = s + 19 * 9
while digs(x - 1) >= s:
	x -= 1
print(max(n - x + 1, 0))


def dsum(n):
	return sum([int(c) for c in str(n)])
(n, s) = map(int, input().split(' '))
l = 1
r = n
while l <= r:
	mid = (l + r) // 2
	delta = mid - dsum(mid)
	if delta >= s:
		r = mid - 1
	else:
		l = mid + 1
print(n - l + 1)


(n, s) = input().split()
l = 1
h = int(n)
while h - l > 1:
	m = (h + l) // 2
	if m - sum(map(int, list(str(m)))) >= int(s):
		h = m
	else:
		l = m
if h - sum(map(int, list(str(h)))) < int(s):
	print(0)
else:
	print(int(n) - h + 1)


def digit_sum(n):
	cnt = 0
	while n:
		cnt += n % 10
		n //= 10
	return cnt

def bsearch(low, high, s):
	h = high
	ans = -1
	while low <= high:
		mid = (low + high) // 2
		if mid - digit_sum(mid) >= s:
			ans = mid
			high = mid - 1
		else:
			low = mid + 1
	if ans == -1:
		return 0
	else:
		return h - ans + 1
(n, s) = map(int, input().split())
st = 1
end = 10
cnt = 0
cnt += bsearch(1, n, s)
print(cnt)


import sys
input = sys.stdin.readline
(n, s) = map(int, input().split())
l = 0
r = n + 1
while r - l > 1:
	x = (l + r) // 2
	cs = 0
	m = x
	while m > 0:
		cs += m % 10
		m //= 10
	if x - cs >= s:
		r = x
	else:
		l = x
print(n - l)


def calc(n):
	val = n
	cnt = 0
	while val:
		cnt += val % 10
		val //= 10
	return n - cnt
(n, s) = list(map(int, input().split()))
if n <= s:
	print(0)
	return
val = s
val //= 10
if val == 0:
	print(n - 9 if n >= 9 else 0)
	return
val *= 10
while calc(val) < s:
	val += 10
	if val > n:
		print(0)
		break
else:
	print(n - val + 1)


def check(n, p):
	k = str(n)
	k = k[::-1]
	s = 0
	for j in range(len(k)):
		s += int(k[j]) * (10 ** j - 1)
	if s >= p:
		return 1
	else:
		return 0
(n, s) = map(int, input().split())
l = 1
h = n
k = 0
while l <= h:
	m = (l + h) // 2
	if check(m, s) == 0:
		l = m + 1
	else:
		h = m - 1
	k += 1
print(n - l + 1)


def main():
	(n, s) = map(int, input().split())
	y = [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s]
	a = y[0]
	print(max(n - a + 1, 0))
main()


def f(n):
	rtn = n
	while 0 < n:
		rtn -= n % 10
		n //= 10
	return rtn
(n, s) = list(map(int, input().split()))
l = 0
r = 10 ** 18 + 1
cnt = 0
while 1 < r - l:
	m = (l + r) // 2
	if s <= f(m):
		r = m
	else:
		l = m
print(max(n - r + 1, 0))


def func(mid, s):
	p = 0
	q = mid
	while mid > 0:
		p += mid % 10
		mid = mid // 10
	if q - p >= s:
		return True
	else:
		return False
(n, s) = map(int, input().split())
do = 1
up = 10 ** 18
an = n + 1
while up >= do:
	mid = (up + do) // 2
	if func(mid, s):
		up = mid - 1
		an = mid
	else:
		do = mid + 1
if an > n:
	print(0)
else:
	print(n - an + 1)


(n, s) = map(int, input().split())
print(max(n - min((i for i in range(s, s + 200) if i - sum(map(int, str(i))) >= s)) + 1, 0))


(n, s) = map(int, input().split())
c = 0
for i in range(s, n + 1):
	x = i - sum((int(t) for t in str(i)))
	if x >= s:
		c = n - i + 1
		break
print(c)


def f(x):
	return x - sum(map(int, list(str(x))))
(n, m) = map(int, input().split())
(l, r) = (0, n + 1)
while l + 1 < r:
	mid = (l + r) // 2
	if f(mid) < m:
		l = mid
	else:
		r = mid
print(n - r + 1)


import atexit, io, sys, collections, math, heapq, fractions, copy, os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, s) = list(map(int, input().split()))
lo = 0
hi = n

def check(n, s):
	return n - sum(map(int, list(str(n)))) >= s
while lo < hi:
	med = (lo + hi) // 2
	if check(med, s):
		hi = med
	else:
		lo = med + 1
print(n - lo + 1 if check(lo, s) else 0)


def cal(a):
	x = 0
	while a > 0:
		x += a % 10
		a = a // 10
	return x
(n, s) = input().split()
n = int(n)
s = int(s)
if n - cal(n) < s:
	print(0)
elif n - 1 - cal(n - 1) < s:
	print(1)
else:
	u = 10
	l = n
	mid = -1
	while 1:
		mid = (u + l) // 2
		if mid - cal(mid) >= s:
			if mid - 1 - cal(mid - 1) < s:
				break
			else:
				l = mid - 1
		elif mid + 1 - cal(mid + 1) >= s:
			mid += 1
			break
		else:
			u = mid + 1
	print(n - mid + 1)


def sum_dig(num):
	num = str(num)
	ans = 0
	for i in range(len(num)):
		ans += int(num[i])
	return ans
(n, s) = map(int, input().split())
ans = 0
for i in range(s, n + 1):
	if i - sum_dig(i) >= s:
		ans = n - i + 1
		break
print(ans)


R = lambda : map(int, input().split())
(n, s) = R()
(l, r) = (s, 10 ** 18 + 7)

def digit(x):
	res = 0
	while x:
		res += x % 10
		x //= 10
	return res
while l < r:
	m = (l + r) // 2
	if m - digit(m) < s:
		l = m + 1
	else:
		r = m
print(max(0, n - l + 1))


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left, bisect
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
(n, k) = map(int, input().split())
(x, y) = (1, n)
f = 0
while x <= y:
	m = (x + y) // 2
	s = 0
	p = m
	while p > 0:
		s += p % 10
		p = p // 10
	m1 = m - 1
	s1 = 0
	p = m1
	while p > 0:
		s1 += p % 10
		p = p // 10
	if m == 0 or (m - s >= k and m1 - s1 < k):
		f = 1
		break
	elif m - s < k:
		x = m + 1
	else:
		y = m - 1
if f:
	print(n - m + 1)
else:
	print(0)


def d(n):
	ret = 0
	n = list(str(n))
	for i in range(len(n)):
		ret += int(n[i])
	return ret

def main():
	(n, s) = map(int, input().split())
	(l, h) = (0, n)
	for i in range(2000):
		m = (l + h) // 2
		if m - d(m) >= s:
			h = m
		else:
			l = m
	for i in range(-100, 100):
		t = m + i
		if t < 0 or t > n:
			continue
		if abs(t - d(t)) >= s:
			print(n - t + 1)
			exit()
	print(0)
main()


I = lambda : map(int, input().split())
(n, s) = I()
cnt = n - min(200 + s, n + 1) + 1
for i in range(s, min(200 + s, n + 1)):
	if i - sum(map(int, str(i))) >= s:
		cnt += 1
print(cnt)


def sumOfDigits(s):
	sum = 0
	s = str(s)
	for i in range(len(s)):
		sum = sum + int(s[i])
	return sum

def binSearch(s, l, u):
	if (l + u) // 2 + 1 - sumOfDigits((l + u) // 2 + 1) >= s and (l + u) // 2 - sumOfDigits((l + u) // 2) < s:
		return (l + u) // 2
	if (l + u) // 2 - sumOfDigits((l + u) // 2) < s:
		return binSearch(s, (l + u) // 2 + 1, u)
	if (l + u) // 2 - sumOfDigits((l + u) // 2) >= s:
		return binSearch(s, l, (l + u) // 2 - 1)
(n, s) = input().strip().split(' ')
s = int(s)
if int(n) - sumOfDigits(n) < s:
	print(0)
else:
	d = binSearch(s, 1, int(n))
	print(int(n) - d)


def bigNumber(n, s):
	for i in range(s, n + 1):
		sumVal = 0
		num = i
		while num:
			sumVal += num % 10
			num //= 10
		if i - sumVal >= s:
			print(n - i + 1)
			return
	print(0)
(n, s) = (int(x) for x in input().split())
bigNumber(n, s)


from __future__ import print_function
from collections import *
from sys import stdin
from bisect import *
from heapq import *
from math import log2
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(n, s) = gil()
(l, r) = (1, n)
ans = r + 1

def isPos(x):
	sm = 0
	X = x
	while x:
		md = x % 10
		sm += md
		x = (x - md) // 10
	return X - sm >= s
while l <= r:
	mid = (l + r) // 2
	if isPos(mid):
		r = mid - 1
		ans = mid
	else:
		l = mid + 1
print(max(0, n - ans + 1))


(n, s) = map(int, input().split())
if s >= n:
	print('0')
	exit()
for i in range(s, n + 2):
	cur = int(0)
	for j in str(i):
		cur += int(j)
	if i - cur >= s:
		break
print(n - i + 1)


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []

def dfs2(root, par, d):
	global gp, dp
	dp[root] = d
	for child in gp[root]:
		if child == par:
			continue
		dfs2(child, root, d + 1)

def hnbhai(tc):
	(n, s) = sd()
	low = s
	high = n + 1
	ans = n + 1
	while low <= high:
		mid = (low + high) // 2
		ss = sum(list(map(int, list(str(mid)))))
		if mid - ss < s:
			low = mid + 1
		else:
			ans = mid
			high = mid - 1
	print(n - ans + 1)
for _ in range(1):
	hnbhai(_ + 1)


def nine(p):
	s = ''
	for i in range(p):
		s += '9'
	return int(s)

def prosh(p):
	ans = 0
	for i in range(1, p + 1):
		ans += nine(i) * 9
	return ans
(n, k) = map(int, input().split())
l = [0] * 29
for i in range(19):
	e = nine(19 - i)
	l[i] = k // e
	k -= l[i] * e
	if k == 0:
		break
	if i == 18 or k % e > prosh(19 - i - 1):
		l[i] += 1
		break
otv = 0
for i in range(19):
	otv += 10 ** (19 - i) * l[i]
print(max(n - otv + 1, 0))


(n, s) = map(int, input().split(' '))

def sumDigit(x):
	s = 0
	while x > 0:
		s += x % 10
		x //= 10
	return s

def lowerBound(l, r):
	while l < r:
		mid = l + r >> 1
		k = mid - sumDigit(mid)
		if k < s:
			l = mid + 1
		else:
			r = mid
	return l
first = lowerBound(0, n + 1)
print(max(0, n - first + 1))


def search(l, r, s, g):
	if l > r:
		return [-1, g]
	mid = (l + r) // 2
	sum = 0
	temp = mid
	while temp > 0:
		sum += temp % 10
		temp //= 10
	if mid - sum == s:
		return [mid - mid % 10, g]
	elif mid - sum > s:
		g = mid - mid % 10
		return search(l, mid - 1, s, g)
	else:
		return search(mid + 1, r, s, g)
(n, s) = map(int, input().split())
g = 0
[num, g] = search(1, n, s, g)
if num == -1 and g == 0:
	print(0)
elif num != -1:
	if num == 0:
		print(n - num)
	else:
		print(n - num + 1)
else:
	print(n - g + 1)


for _ in range(1):
	(n, s) = map(int, input().split())
	lo = 0
	hi = n
	ans = n + 1
	while lo <= hi:
		mi = lo + hi >> 1
		curr = sum((int(i) for i in str(mi)))
		if mi - curr >= s:
			hi = mi - 1
			ans = mi
		else:
			lo = mi + 1
	print(n - ans + 1)


def digit(a):
	s = 0
	while a:
		s += a % 10
		a //= 10
	return s

def big(n, s):
	lo = 1
	hi = n
	while lo <= hi:
		mid = (lo + hi) // 2
		if mid - digit(mid) < s:
			lo = mid + 1
		else:
			hi = mid - 1
	return n - lo + 1
(a, b) = map(int, input().strip().split())
print(big(a, b))


import sys
(n, s) = map(int, input().split())
(ok, ng) = (10 ** 18 + 100, -1)
while abs(ok - ng) > 1:
	mid = ok + ng >> 1
	if mid - sum(map(int, str(mid))) >= s:
		ok = mid
	else:
		ng = mid
print(max(0, n - ok + 1))


def main():
	(n, s) = input().split()
	n = int(n)
	s = int(s)
	ans = n
	ans -= s - 1
	count = 0
	for i in range(s, n + 1):
		i_str = list(str(i))
		total = 0
		for j in i_str:
			total += int(j)
		if i - total >= s:
			break
		count += 1
	ans -= count
	if ans < 0:
		print(0)
	else:
		print(ans)
main()


raw = input().split()
n = int(raw[0])
s = int(raw[1])

def sum_digits(x):
	z = 0
	while x:
		z += x % 10
		x //= 10
	return z
i = s
count = 0
while i <= n:
	q = i - sum_digits(i)
	if q >= s:
		count = n - i + 1
		break
	else:
		i += 1
print(count)


(n, s) = map(int, input().split())

def R(n):
	ans = 0
	while True:
		ans += n % 10
		n = n // 10
		if n == 0:
			return ans
current = n - R(n)
if current < s:
	print('0')
else:
	extra = n % 10 + 1
	(lo, hi) = (0, n)
	while lo < hi - 1:
		mid = lo + (hi - lo) // 2
		if mid - R(mid) < s:
			lo = mid
		else:
			hi = mid
	print(n - hi + 1)


(n, s) = map(int, input().split())
l = 1
r = n + 1
while r > l + 1:
	m = (l + r) // 2
	line = str(m)
	if m - sum((int(k) for k in line)) >= s:
		r = m
	else:
		l = m
line = str(l)
if l - sum((int(k) for k in line)) >= s:
	r = l
print(max(n - r + 1, 0))


def f(x):
	ans = x
	while x > 0:
		ans -= x % 10
		x //= 10
	return ans
(n, s) = map(int, input().split())
if f(n) < s:
	print(0)
	exit(0)
(l, r) = (1, n)
while l < r:
	m = (l + r) // 2
	if f(m) >= s:
		r = m // 10 * 10
	else:
		l = m + 1
print(n - l + 1)


def main():

	def sumofdigit(n):
		temp = 0
		while n > 0:
			temp += n % 10
			n = n // 10
		return temp

	def F(x):
		return x - sumofdigit(x)

	def findout(s):
		test = s - s % 10 + 10
		while 1:
			if F(test) >= s:
				break
			else:
				test += 10
		return test
	(n, s) = list(map(int, input().strip().split(' ')))
	L = findout(s)
	ans = n - L + 1
	if ans < 0:
		print(0)
	else:
		print(ans)
main()


[n, s] = map(int, input().strip().split())

def sumdigit(x):
	return sum(map(int, str(x)))

def fsum(x):
	return x - sumdigit(x)

def binsearch(s, xmin, xmax):
	while xmax - xmin > 1:
		xmid = (xmax + xmin) // 2
		if fsum(xmid) >= s:
			xmax = xmid
		else:
			xmin = xmid
	return xmax
xmin = 0
xmax = 1
while fsum(xmax) < s:
	xmin = xmax
	xmax *= 2
x = binsearch(s, xmin, xmax)
print(max(n - x + 1, 0))


import sys

def calculate():
	input = sys.stdin.readline().split()
	n = int(input[0])
	s = int(input[1])
	count = 0
	i = s // 10 * 10
	while i <= n:
		if i - sumOfDigits(i) >= s:
			count = n - i + 1
			break
		i = i + 10
	print(count)

def sumOfDigits(numb):
	sum = 0
	while numb > 0:
		sum = sum + numb % 10
		numb = numb // 10
	return sum
calculate()


import math
from math import log2, sqrt
from bisect import bisect_left, bisect_right
import bisect
import sys
from sys import stdin, stdout
import os
sys.setrecursionlimit(pow(10, 6))
import collections
from collections import defaultdict
from statistics import median
inf = float('inf')

def sum_of_no(n):
	suma = 0
	while n:
		suma += n % 10
		n //= 10
	return suma

def get_forward(start, diff):
	if diff == 0:
		return [start + 1, diff]
	diff = diff // 2
	start += diff
	return [start, diff]

def get_backward(start, diff):
	if diff == 0:
		return [start - 1, diff]
	diff = diff // 2
	start -= diff
	return [start, diff]
(n, s) = map(int, input().split())
start = 1
end = n
diff = n - 1
ans = 0
while 1:
	sub = start - sum_of_no(start)
	sub_prev = start - 1 - sum_of_no(start - 1)
	if sub >= s and sub_prev < s:
		ans = start
		break
	if sub >= s:
		(start, diff) = get_backward(start, diff)
	elif sub < s:
		(start, diff) = get_forward(start, diff)
real_ans = n - ans + 1
if real_ans < 0:
	real_ans = 0
print(real_ans)


def check(x, s):
	k = 0
	for i in str(x):
		k += int(i)
	return x - k >= s
(n, s) = map(int, input().split())
l = 0
r = n
while r - l > 1:
	m = (l + r) // 2
	if check(m, s):
		r = m
	else:
		l = m
if check(r, s):
	print(n - r + 1)
else:
	print(0)


def works(mid, s):
	return mid - sum(list(map(int, list(str(mid))))) >= s

def main():
	(n, s) = map(int, input().strip().split())
	low = 0
	high = n + 1
	while low + 1 < high:
		mid = (low + high) // 2
		if works(mid, s):
			high = mid
		else:
			low = mid
	print(n - low)
main()


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(n, s) = map(int, input().split())
	if n < 10:
		print(0)
		return
	tmp = n // 10
	digit = []
	while tmp > 0:
		digit.append(tmp % 10)
		tmp = tmp // 10
	weight = [10 ** i - 1 for i in range(1, len(digit) + 1)]
	mn = n + 1
	for i in range(len(digit) - 1, -1, -1):
		if s // weight[i] > 9:
			break
		if s < weight[i]:
			if 10 ** (i + 1) >= s:
				mn = min(mn, 10 ** (i + 1))
			continue
		temp = s
		j = i
		ans = 0
		while j >= 0:
			t = temp // weight[j]
			if t > 9:
				temp = 0
				ans += 10 ** (j + 2)
				break
			ans += t * 10 ** (j + 1)
			temp = temp - t * weight[j]
			j = j - 1
		if ans != 0:
			ans += math.ceil(temp / 9) * 10
			mn = min(ans, mn)
	if mn > n:
		print(0)
	else:
		print(n - mn + 1)
main()


def cmp(x1=[], x2=[]):
	len1 = len(x1)
	len2 = len(x2)
	if len1 == len2:
		for i in range(len1):
			n1 = x1[len1 - 1 - i]
			n2 = x2[len1 - 1 - i]
			if n1 != n2:
				return n1 > n2
	else:
		return len1 > len2
	return True

def add(x1=[], x2=[]):
	if not cmp(x1, x2):
		(x1, x2) = (x2, x1)
	len1 = len(x1)
	len2 = len(x2)
	for i in range(len1 - len2):
		x2.append(0)
	res = []
	flag = 0
	for (n1, n2) in zip(x1, x2):
		m = n1 + n2 + flag
		flag = m // 10
		res.append(m % 10)
	if flag:
		res.append(flag)
	return res

def minus(x1=[], x2=[]):
	if not cmp(x1, x2):
		(x1, x2) = (x2, x1)
	len1 = len(x1)
	len2 = len(x2)
	for i in range(len1 - len2):
		x2.append(0)
	res = []
	flag = 0
	for (n1, n2) in zip(x1, x2):
		m = n1 - n2 + flag
		flag = 0 if m >= 0 else -1
		res.append((m + 10) % 10)
	while res and (not res[-1]):
		res.pop()
	return res

def div(x1=[], x2=9):
	if x2 == 10:
		return x1[1:]
	else:
		x1.reverse()
		res = []
		mod = 0
		for n in x1:
			res.append((n + mod * 10) // 9)
			mod = (n + mod * 10) % 9
	res.reverse()
	while res and (not res[-1]):
		res.pop()
	return res

def multi(x1=[], x2=9):
	x1_copy = x1.copy()
	x1.insert(0, 0)
	if x2 == 10:
		return x1
	else:
		return minus(x1, x1_copy)
input_str = input()
(n, s) = [a for a in input_str.split()]
nl = list([int(a) for a in list(n)])
sl = list([int(a) for a in list(s)])
nl.reverse()
sl.reverse()
x = multi(div(add(sl.copy(), [8]), 9), 9)
y = multi(div(add(x.copy(), [9]), 10), 10)
sumy = list([int(a) for a in list(str(sum(y)))])
sumy.reverse()
while not cmp(minus(y, sumy), sl):
	y = add(y, [0, 1])
	sumy = list([int(a) for a in list(str(sum(y)))])
	sumy.reverse()
if cmp(nl, y):
	ans = add(minus(nl, y), [1])
else:
	ans = [0]
ans.reverse()
ansstr = [str(a) for a in ans]
print(''.join(ansstr))


arr = [int(x) for x in input().split()]
n = arr[0]
s = arr[1]
resp = 0
leng = len(str(s))
j = 0
for i in range(s, s + leng * 9 + 1):
	j = i
	if i > n:
		break
	temp = 0
	c = i
	while c:
		temp += c % 10
		c //= 10
	if i - temp >= s:
		resp += 1
j += 1
if j > n:
	print(resp)
else:
	print(n - j + 1 + resp)


(n, s) = map(int, input().split())

def nod(n):
	res = 0
	while n > 0:
		res += 1
		n //= 10
	return res

def sod(n):
	res = 0
	while n > 0:
		res += n % 10
		n //= 10
	return res

def maxsod(n):
	if (n + 1) % 10 ** (nod(n) - 1) == 0:
		return 9 * (nod(n) - 1) + n // 10 ** (nod(n) - 1)
	else:
		return 9 * (nod(n) - 1) + (n - 1) // 10 ** (nod(n) - 1)
num = max(n - s, 0)
for i in range(s + 1, min(s + maxsod(n), n) + 1):
	if i - sod(i) < s:
		num -= 1
print(num)


def find(curr_pos, max_pos, curr_s, choose):
	if curr_pos == 0:
		if curr_s <= 0:
			return True
		else:
			return False
	if curr_pos == max_pos:
		low = 1
	else:
		low = 0
	high = 9
	for d in range(low, high + 1):
		curr_val = d * (10 ** curr_pos - 1)
		if curr_val + p[curr_pos - 1] < curr_s:
			continue
		choose[curr_pos] = d
		return find(curr_pos - 1, max_pos, curr_s - curr_val, choose)
	return False
(n, s) = map(int, input().split())
p = [0]
for i in range(1, 19):
	p.append(p[-1] + 9 * (10 ** i - 1))
choose = [0] * 19
ans = n + 1
for num_digit in range(1, 19):
	for i in range(1, num_digit + 1):
		choose[i] = 0
	if find(num_digit, num_digit, s, choose):
		res = 0
		for i in range(num_digit, -1, -1):
			res = res * 10 + choose[i]
		ans = min(ans, res)
		break
print(n - ans + 1)


(n, s) = map(int, input().rstrip().split())
if n <= s:
	print(0)
	exit()
for i in range(s, n + 2):
	l = 0
	for j in str(i):
		l += int(j)
	if i - l >= s:
		break
print(max(n - i + 1, 0))


def digisum(n):
	count = 0
	while n > 0:
		count += n % 10
		n = n // 10
	return count
(n, s) = list(map(int, input().split()))
(l, r) = (1, n)
flag = 0
while l < r:
	m = l + (r - l) // 2
	digi_sum = digisum(m)
	num = m
	if num - digi_sum >= s:
		flag = 1
		cur = m
		r = m
	else:
		l = m + 1
	if r - l == 1:
		digi_sum = digisum(l)
		num = l
		if num - digi_sum >= s:
			flag = 1
			cur = l
			break
		digi_sum = digisum(r)
		num = r
		if num - digi_sum >= s:
			flag = 1
			cur = r
			break
if flag == 0:
	digi_sum = digisum(l)
	num = l
	if num - digi_sum >= s:
		flag = 1
		cur = l
if flag == 0:
	print(0)
else:
	print(n - cur + 1)


(n, s) = map(int, input().strip().split())
num = ''
div = 9
if s // 10 != 0:
	div = 9
	while s // div // 10 != 0:
		div = div * 10 + 9
	while div:
		rem = str(s // div)
		if int(rem) > 9:
			num = str(int(num) + 1) + '0' * len(str(div))
			div = 0
			s = 0
			break
		else:
			num += rem
		s = s % div
		div //= 10
	num += str(s)
else:
	num = str(s)
mini = int(num)
if mini % 10 != 0:
	mini += 10
	mini -= mini % 10
print(max(0, n - mini + 1))


def forninho(miolo, s):
	premiolo = miolo
	temp = 0
	while miolo > 0:
		temp += miolo % 10
		miolo = miolo // 10
	if premiolo - temp >= s:
		return 1
	else:
		return 0
entrada = input().split()
n = int(entrada[0])
s = int(entrada[1])
result = -1
l = 1
r = n
while r - l >= 0:
	miolo = (l + r) // 2
	if forninho(miolo, s) == 1:
		r = miolo - 1
		result = miolo
	else:
		l = miolo + 1
if result == -1:
	print('0')
else:
	print(n - result + 1)


(n, s) = map(int, input().split())
if s >= n:
	print(0)
else:
	ans = 0

	def sod(n):
		s = str(n)
		ret = 0
		for i in s:
			ret += int(i)
		return ret
	for nd in range(s, s + 1000):
		if nd - sod(nd) >= s:
			ans += 1
		if nd == n:
			break
		if nd == s + 369:
			ans += n - nd
			break
	print(ans)


def qtd(u):
	ans = 0
	while u > 0:
		u //= 10
		ans += 1
	return ans

def digitos(u):
	ans = 0
	while u > 0:
		ans += u % 10
		u //= 10
	return ans
(n, m) = input().split()
m = int(m)
number = int(n)
ans = 0
size_n = qtd(m)
i = m
while i < m + size_n * 9 + 1:
	if i > number:
		break
	if i - digitos(i) >= m:
		ans += 1
	i += 1
if i > number:
	print(ans)
else:
	print(number - i + 1 + ans)


def mus(x):
	c = 0
	while x > 0:
		c += x % 10
		x = x // 10
	return c
(n, s) = map(int, input().split())
ans = s + 10 - s % 10
while ans - mus(ans) < s:
	ans += 10
if ans > n:
	print(0)
else:
	print(n - ans + 1)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	(n, s) = map(int, input().split())
	(lo, hi) = (s, n)
	ans = n + 1
	while lo <= hi:
		mid = (lo + hi) // 2
		z = sum(map(int, str(mid)))
		if mid >= s + z:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(n - ans + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def somaDigitos(x):
	resp = 0
	while x > 0:
		resp += x % 10
		x = x // 10
	return resp

def isReallyBigNumber(x):
	return x - somaDigitos(x) >= s
(n, s) = input().split(' ')
n = int(n)
s = int(s)
count = 0
ini = 1
fim = n
i = 0
ans = False
while ini <= fim:
	meio = (ini + fim) // 2
	if isReallyBigNumber(meio):
		ans = meio
		fim = meio - 1
	else:
		ini = meio + 1
if ans:
	print(n - ans + 1)
else:
	print(0)


def f(x):
	return x if x < 10 else f(x // 10) + x % 10
(n, s) = map(int, input().split())
x = s
while x - f(x) < s:
	x += 1
print(max(0, n - x + 1))


(n, s) = map(int, input().split())
counter = 0
if n >= s:
	for d in range(s, n + 1):
		c = 0
		f = d
		while d != 0:
			e = d % 10
			c = c + e
			d = int(d // 10)
		check = f - c
		if check < s:
			counter = counter + 1
		else:
			break
	x = n + 1 - counter - s
	print(x)
else:
	x = 0
	print(x)


def read_ints():
	return list(map(int, input().split()))
(n, s) = read_ints()

def judge(x):
	return x - sum(map(int, str(x))) >= s
result = len([x for x in range(s, min(n, s + 180) + 1) if judge(x)]) + max(0, n - s - 180)
print(result)


(n, s) = map(int, input().split())

def binsearch(n, s):
	left = 0
	right = n
	while left <= right:
		mid = (left + right) // 2
		digits = sum([int(i) for i in list(str(mid))])
		if mid - digits >= s:
			right = mid - 1
		else:
			left = mid + 1
	return right
print(max(0, n - binsearch(n, s)))


def somadig(x):
	soma = 0
	while x > 0:
		soma += x % 10
		x = x // 10
	return soma

def main():
	(x, s) = map(int, input().split())
	comeco = 9
	fim = x
	if comeco >= fim:
		print(0)
		return
	while fim >= comeco:
		meio = (fim + comeco) // 2
		if meio - somadig(meio) >= s:
			if meio - 1 - somadig(meio - 1) < s:
				print(x - (meio - 1))
				return
			fim = meio - 1
		else:
			comeco = meio + 1
	print(0)
	return
main()


(n, s) = map(int, input().split())

def ver(i):
	t = str(i)
	ans = 0
	for j in t:
		ans += int(j)
	return ans
l = len(str(s))
if n < s:
	print(0)
	exit()
if s + 10 * (l ** 2 + 1) <= n:
	ans = n - s + 1 - 10 * (l ** 2 + 1)
	for i in range(s, s + 10 * (l ** 2 + 1)):
		if s + ver(i) <= i:
			ans += 1
else:
	ans = 0
	for i in range(s, n + 1):
		if s + ver(i) <= i:
			ans += 1
print(ans)


import sys
from bisect import bisect_right as lb
from collections import deque
from queue import PriorityQueue as pq
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
(n, s) = il()
l = s
h = n
ans = n + 1
while l <= h:
	m = (l + h) // 2
	t = 0
	for i in str(m):
		t += int(i)
	if m - t >= s:
		ans = m
		h = m - 1
	else:
		l = m + 1
print(n - ans + 1)


(n, s) = map(int, input().split())
r = 0
v = min(n + 1, s + 19 * 9)
for i in range(s, v):
	zz = f'{i}'
	sm = i
	for z in zz:
		sm -= int(z)
	if sm >= s:
		r += 1
print(r + n - v + 1)


def readints():
	return [int(item) for item in input().strip().split()]

def f(n):
	return n - sum(map(int, str(n)))

class Solver:

	def main(self):
		(n, s) = readints()
		if f(n) < s:
			print('0')
			return
		(l, r) = (1, n)
		while l <= r:
			mid = (l + r) // 2
			if f(mid) < s:
				l = mid + 1
			if f(mid) >= s:
				r = mid - 1
		print(n - r)
Solver().main()


def sum_of_digits(n):
	ans = 0
	while n:
		ans += n % 10
		n //= 10
	return ans
(n, s) = map(int, input().split())
lo = 0
hi = n
x = n + 1
while lo <= hi:
	mid = (lo + hi) // 2
	if mid - sum_of_digits(mid) >= s:
		x = min(mid, x)
		hi = mid - 1
	else:
		lo = mid + 1
print(n - x + 1)


def bin(num):
	i = 9 * num * 11
	count = 0
	add = 0
	for j in range(100):
		add = 0
		a = str(i)
		for k in range(10):
			add += a.count(str(k)) * k
		if i - add >= s:
			return i
		i += 1
	return -1
(n, s) = map(int, input().split())
i = 0
j = 10 ** 30
limit = 0
while i < j:
	m = (i + j) // 2
	if bin(m) == -1:
		i = m + 1
	else:
		j = m
print(max(0, n - bin(i) + 1))


(n, s) = map(int, input().split())
mult_10 = s if not s % 10 else s + 10 - s % 10
for i in range(mult_10, mult_10 + 100000, 10):
	if i - sum([int(c) for c in str(i)]) >= s:
		low = i
		break
print(max(n - low + 1, 0))


inp = input().split()
n = int(inp[0])
s = int(inp[1])
start = s + 1
thresh = s + 500
ans = 0
if n > thresh:
	ans += n - thresh
else:
	thresh = n
val = 0
for i in range(start, thresh + 1):
	val = i
	while i > 0:
		val -= i % 10
		i = i // 10
	if val >= s:
		ans += 1
print(ans)


(n, s) = list(map(int, input().split()))

def sum_of_digits(n):
	ans = 0
	for c in str(n):
		ans += int(c)
	return ans
m = s + 10 - s % 10
while m - sum_of_digits(m) < s:
	m += 10
if m <= n:
	print(n - m + 1)
else:
	print(0)


(n, s) = input().split()
n = int(n)
s = int(s)

def get_decimal_value_digits(number):
	count = 0
	digits = 0
	number = str(number)
	for digit in number:
		count += int(digit)
		digits += 1
	return count

def is_big_num(number, s):
	if number - get_decimal_value_digits(number) >= s:
		return True
	return False
start = s
end = n
count = 0
digits = 0
half = (n + s) // 2
while end - start >= 0:
	half = (start + end) // 2
	if is_big_num(half, s):
		end = half - 1
	else:
		start = half + 1
if not is_big_num(start + 1, s):
	print(0)
else:
	print(n - start + 1)


(n, s) = map(int, input().split())
mdist = 10 ** 5
c = s
ans = 0

def mySum(c):
	s = str(c)
	ret = 0
	for x in s:
		ret += ord(x) - ord('0')
	return ret
while mdist and c <= n:
	if c - mySum(c) >= s:
		ans += 1
	mdist -= 1
	c += 1
c = min(c, n + 1)
print(ans + n - c + 1)


def summing(number):
	summa = 0
	while number > 0:
		summa += number % 10
		number = number // 10
	return summa

def result(n, s):
	z = min(s, n)
	while z <= n and z - summing(z) < s:
		z += 1
	return n - z + 1
(a, b) = [int(i) for i in input().split()]
print(result(a, b))


from math import ceil
(n, s) = [int(i) for i in input().split()]
l = 0
r = 10000000000000000000
while l < r:
	cur = (l + r) // 2
	sm = sum([int(i) for i in str(cur)])
	if cur - sm >= s:
		r = cur
	else:
		l = cur + 1
print(max(0, n - l + 1))


(n, s) = map(int, input().split())

def comp(p):
	a = p
	sum = 0
	while a != 0:
		sum += a % 10
		a //= 10
	return p - sum >= s
l = 0
r = n
while r - l > 1:
	p = (l + r) // 2
	if comp(p):
		r = p
	else:
		l = p
if comp(n):
	print(n - l)
else:
	print(0)


a = input()
a = a.split(' ')
a = list(map(int, a))

def really_big(n, s):
	if s >= n:
		return 0
	i = s + 1
	while i <= n:
		(t, b) = (i, 0)
		while t > 0:
			b = b + t % 10
			t = t // 10
		if i - b >= s:
			return n - i + 1
			break
		else:
			i += 1
	return 0
print(really_big(a[0], a[1]))


(n, s) = map(int, input().split())
(x, y) = divmod(s, 9)
if not s:
	x = 0
elif y:
	x += 1
low = x * 9
for i in range(low, low + 10000):
	if i - sum([int(c) for c in str(i)]) >= s:
		low = i
		break
print(max(n - low + 1, 0))


(n, s) = map(int, input().split())
if s >= n:
	print('0')
else:
	for i in range(s, n + 2):
		l = 0
		for j in str(i):
			l += int(j)
		if i - l >= s:
			break
	print(n - i + 1)


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)

def ok(x):
	y = sum(map(int, list(str(x))))
	return x - y >= s
(n, s) = map(int, input().split())
(l, h) = (0, n)
a = n
while l <= h:
	m = l + h >> 1
	if ok(m):
		a = m - 1
		h = m - 1
	else:
		l = m + 1
print(n - a)


def sum_of_its_digits(Num, s):
	S = str(Num)
	sum = 0
	for i in S:
		sum += int(i)
	return Num - sum >= s
k = input().split()
n = int(k[0])
s = int(k[1])
sum = 0
for i in range(s, n + 1):
	if sum_of_its_digits(i, s):
		sum = n - i + 1
		break
print(sum)


(n, s) = map(int, input().split())
r = 10 ** 18 + 1
l = 0

def f(m):
	res = 0
	while m > 0:
		res += m % 10
		m //= 10
	return res
while r - l > 1:
	mid = (r + l) // 2
	if mid - f(mid) >= s:
		r = mid
	else:
		l = mid
print(max(n - r + 1, 0))


(n, s) = list(map(int, input().split()))
if n - sum([int(x) for x in str(n)]) < s:
	print(0)
else:

	def check(n):
		return n - sum([int(x) for x in str(n)]) >= s
	start = 1
	end = n
	mid = (start + end) // 2
	while mid != end and mid != start:
		if check(mid):
			end = mid
			mid = (start + end) // 2
		else:
			start = mid
			mid = (start + end) // 2
	print(n - end + 1)


from sys import stdin, stdout
(n, s) = map(int, stdin.readline().split())
l = 0
r = n + 1
while r - l > 1:
	f = lambda x: sum(map(int, list(str(x))))
	m = (r + l) // 2
	if m - f(m) >= s:
		r = m
	else:
		l = m
while r == f(r):
	r += 1
stdout.write(str(max(0, n - r + 1)))