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.

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

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

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

n,s=map(int,raw_input().split())
a,b=1,n+1
while a<b:
  c=(a+b)/2
  if c-sum(map(int,str(c)))<s:
    a=c+1
  else:
    b=c
print n-a+1

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

def dif(x):
    tmp = x
    while tmp > 0:
        x = x - tmp % 10
        tmp = tmp/10
    return x

l = 0
r = 2000000000000000000
while l < r:
    m = (l + r)/2
    if dif(m) < s:
        l = m + 1
    else: r = m
d = l

while d % 10 > 0: d -= 1

if n < d: print 0
else: print n - d + 1

N,S = map(int,raw_input().split())
ans = 0
for i in range(S,min(S+10000,N+1)):
    if i-sum([int(x) for x in str(i)])<S:
        ans += 1
print max(N-S+1-ans,0)

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)

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)

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

n, s = map(int, raw_input().split())
ans = 0
for i in xrange(300):
    if s + i > n:
        break
    t = s + i - sum(map(int, str(s + i)))
    if t >= s:
        ans += 1
else:
    ans += n - s - 299
print ans

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)

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

dign = map(int, str(n))

l = len(dign)
pw = [1] * l

for i in xrange(1, l):
  pw[i] = pw[i - 1] * 10

def cnt(digc, s):
  if s <= 0:
    return pw[digc]
  if s >= pw[digc] - 1:
    return 0
  ret = 0
  for i in xrange(10):
    ret += cnt(digc - 1, s - (pw[digc - 1] - 1) * i)
  return ret

ret = 0
ns = s
for i in xrange(l):
  for j in xrange(dign[i]):
    ret += cnt(l - i - 1, ns - (pw[l - i - 1] - 1) * j)
    #print('ret', ret)
  ns = ns - dign[i] * (pw[l - i - 1] - 1)
  #print('ns', ns)

if s == 0:
  ret -= 1

if n - sum(dign) >= s:
  ret += 1

print(ret)

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)

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

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,raw_input().split())
l,r=1,n+1
while l<r:
    mid=(l+r)/2
    if mid-sum(map(int,str(mid)))<s:
        l=mid+1
    else:
        r=mid
print n-l+1

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

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

# count = 0
# summ = sum_digits(n)
# # k = sum_digits(n - n%10 - 1)
# # print(k)
# for num in range(n, 9, -1):
# 	if num % 10 == 9:
# 		summ = sum_digits(num)
# 	# print(num, summ)
# 	if num - summ  >= s:
# 		count += 1
# 	summ -= 1

# print(count)

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)
	# print(s,s2)
	while not(s2 >= elem and s < elem): #s >= elem and s1 < elem or
		# print(l,medium,r)
		if s < elem:
			l = medium
		elif s >= elem:
			r = medium
		k = medium
		medium = (l + r ) // 2
		if k == medium:
			break
		# print(l,medium,r)
		s = medium - sum_digits(medium)
		s2 = medium+1 - sum_digits(medium+1)
		# print(s,s2)

	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 = map(int, input().split())
# a = [i for i in range(n+1)]
if n == s:
	print(0)
else:

	y = binsearch( 0, n, s)
# print(y)
	print(n - y + 1)

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) #Search in a bigger range to detect errors, O(log²n)
print(max(0, n - first + 1))

R = lambda:map(int,raw_input().split())

n,s = R()

l,r = 1,n+1

while l<r:
    mid= (l+r)/2
    if mid - sum(map(int,list(str(mid)))) >= s:
	r=mid
    else:
	l=mid+1

print n-l+1

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): # mid is really big
            right = mid - 1
            ans = n - mid + 1
        else: # mid is not really big
            left = mid + 1
    return ans
"""
25 20
"""

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

import re

def get_index(s):
	l = []
	for x in range(0,len(s)):
		if s[x]=='b':
			l.append(x)
	return l
def check(num1,s):
	ans = sum(map(lambda x:int(x),num1))

	if(int(num1)-ans)>=s:
		return True
	return False

def gen(frst,last,s):
	if last-frst==1:
		return last if check(str(last),s) else last+1
	if(check(str(frst+int((last-frst)/2)),s)):
		return gen(frst,frst+int((last-frst)/2),s)
	else:
		return gen(frst+int((last-frst)/2),last,s)

def main():
	nums = raw_input().split(' ')
	nums = map(lambda x:int(x),nums)
	maxi = nums[0]
	print maxi-int(gen(0,nums[0],nums[1]))+1

if __name__ == "__main__":
	# while True:
	# 	main()
	main()

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:
		#print((l+u)//2)
		return (l+u)//2
	if (((l+u)//2) - sumOfDigits(((l+u)//2))) < s:
		#print((l+u)//2)
		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)
# print(sumOfDigits(int(n)))
if int(n) - sumOfDigits(n)<s:
	print(0)
else:
	d = binSearch(s, 1, int(n))
	# print(d)
	# while d-sumOfDigits(d) >= s:
	# 	e = str(d)
	# 	d = d - int(e[len(e)-1]) - 1
	print(int(n) - d)

stuff = [int(i) for i in raw_input().split()]

n = int(stuff[0])
s = int(stuff[1])

def f(x):
    return x - sum(int(i) for i in list(str(x)))

mi = 0
ma = n
found = False

while ma >= mi and found == False:
    mid = (mi + ma)/2
    test = f(mid)
    if test >= s:
        ma = mid - 1
    elif test < s:
        if f(mid + 1) >= s:
            found = True
        else:
            mi = mid + 1

print n - mid

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 = map(int, raw_input().split())

def cal(x):
    tmp = x
    while x > 0:
        tmp -= x % 10
        x = x / 10
    return tmp

lo = 0
hi = n
res = -1
while lo <= hi:
    mid = (lo + hi) / 2
    if cal(mid) >= s:
        res = mid
        hi = mid - 1
    else:
        lo = mid + 1

if res == -1:
    print 0
else:
    print n - res + 1

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

mod=1000000007

import math

def main():

    n,s=mi()
    lo=1
    hi=2000000000000000000
    while(lo<hi):
        mid=(lo+hi)//2
        #print(mid)
        a=mid-su(mid)
        if a>s:
            hi=mid-1
        elif a<s:
            lo=mid+1
        else:
            break
    if mid-su(mid)<s:
        c=int(math.ceil(mid/10))
        print(max(0,n-c*10+1))
        exit()
    c=mid//10
    print(max(0,n-c*10+1))

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

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)

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)

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
def F(i):
	return (i - sum([int(j) for j in str(i)]))
n,s=map(int,raw_input().split())
l=0
h=n+1
mid=0
b=0
while(l<h):
	mid=l+(h-l)/2
	# print mid, F(mid)
	# print mid
	if(F(mid) >= s and F(mid-1) < s):
		# print n-mid
		# print mid, mid+1
		# print F(mid), F(mid+1)
		b=1
		break
	elif(F(mid) < s):
		l=mid+1
	else:
		h=mid
if(b):
	print n-mid+1
else:
	print n-mid

# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-19 14:49
# @url:https://codeforc.es/contest/817/problem/C
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

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")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
## 精度 print("%.10f" % ans)
## sqrt:int(math.sqrt(n))+1
## 字符串拼接不要用+操作，会超时
## 二进制转换:bin(1)[2:].rjust(32,'0')
## array copy:cur=array[::]
## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200
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)]
    # print (weight,digit)
    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)
    # print (mn)
    if mn>n:
        print (0)
    else:
        print (n-mn+1)

if __name__ == "__main__":
    main()

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

def f(n):
    rtn = n
    while 0 < n:
        rtn -= n % 10
        n //= 10
    return rtn

n, s = 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 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))

def legit(mid,s):
    digit = 1
    digitsum = 0

    while mid > 0:
        digitsum += (digit - 1) * (mid % 10)
        digit *= 10
        mid /= 10

    return digitsum >= s

def bi(s):
    low = 1
    high = 10**18

    while low <= high:
        if low + 1 >= high:
            if legit(low,s):
                return low
            elif legit(high,s):
                return high
            else:
                return 10**19

        mid = (low + high) / 2

        if legit(mid,s):
            high = mid
        else:
            low = mid + 1

n,s = [int(_) for _ in raw_input().split()]

x = bi(s)

print max(0,n-x+1)

n , k = map(int, raw_input().split())

def sum(k):
	s = 0
	while k > 0:
		s += k%10
		k /= 10
	return s

t = k
while t <= n:
	d = t - sum(t)
	if d >= k:
		break
	t += 1

ans = n - t + 1
if ans < 0:
    ans = 0
print ans

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

# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-19 14:49
# @url:https://codeforc.es/contest/817/problem/C
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

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")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
## 精度 print("%.10f" % ans)
## sqrt:int(math.sqrt(n))+1
## 字符串拼接不要用+操作，会超时
## 二进制转换:bin(1)[2:].rjust(32,'0')
## array copy:cur=array[::]
## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200
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
        ans+=math.ceil(temp/9)*10
        mn=min(ans,mn)
    if mn>n:
        print (0)
    else:
        print (n-mn+1)

if __name__ == "__main__":
    main()

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

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

# Made By Mostafa_Khaled

def R() : return map(int,raw_input().strip().split())
def Rf() : return map(float,raw_input().strip().split())
def Sl() : return raw_input().strip().split()

[n,s] = R()
lo, hi = 1,n+1

while lo < hi:
	sm = 0
	mid = lo + (hi-lo)/2
	p = mid
	while p != 0:
		sm += p%10
		p /= 10
	if(mid - sm >= s):
		hi = mid
	else:
		lo = mid+1

print (n-lo+1)

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)

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

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

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

def cal(x):
    tmp = x
    while x > 0:
        tmp -= x % 10
        x = x / 10
    return tmp

lo = 0
hi = n
res = -1
while lo <= hi:
    mid = (lo + hi) / 2
    if cal(mid) >= s:
        res = mid
        hi = mid - 1
    else:
        lo = mid + 1

if res == -1:
    print 0
else:
    print n - res + 1

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

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

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

if __name__ == "__main__":
    main()

n , k = map(int, raw_input().split())

def sum(k):
	s = 0
	while k > 0:
		s += k%10
		k /= 10
	return s

t = k
while t <= n:
	d = t - sum(t)
	if d >= k:
		break
	t += 1

ans = n - t + 1
if ans < 0:
    ans = 0
print ans

n,s = raw_input().split()
def msmdez(x,y):
	x,y = int(x),int(y)
	x1,y1 = str(x),str(y)
	if len(x1) == len(y1) != 1:
		if abs(x-y) < 10:
			return x1[-2] == y1[-2]
	return False
md = msmdez(n,s)
if int(n) <= int(s):
	print 0
	exit()
if int(n) < int(s) + sum(map(int,list(n))) and not md:
	print 0
	exit()
n,s = int(n),int(s)
if s < 10 :
	print n - 10 + 1
	exit()
if md:
	print 0
	exit()
S = s
while S <= n and not msmdez(S,n):
	k = S - sum(map(int,list(str(S))))
	if k >= s: break
	S+=10
if S - sum(map(int,list(str(S)))) < s:
	print int(str(n)[-1]) + 1
	exit()
print n  - (S - int(str(S)[-1])) + 1

n,s=map(int,raw_input().split())
l,r=1,n+1
while l<r:
    mid=(l+r)/2
    if mid-sum(map(int,str(mid)))<s:
        l=mid+1
    else:
        r=mid
print n-l+1

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,raw_input().split())
x=s/9
if s%9>0:
    x+=1
z=0
l=len(str(s))
d='1'*l
d=int(d)
while d!=0:
    m=x//d
    z=z*10+m
    x-=m*d
    d=d//10
z*=10
if z<=n:
    print n-z+1
else:
    print 0

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)

n, s  = [int(i) for i in input().split()]
print(max(n - ([i for i in range(s, s + 9 * 18 + 1) if i - sum([int(j) for j in str(i)]) >= s] + [int('1' *  18)])[0] + 1, 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
        else:
            if((mid+1-cal(mid+1))>=s):
                mid+=1
                break
            else:
                u=mid+1
    print(n-mid+1)

def f(n):
    rtn = n
    while 0 < n:
        rtn -= n % 10
        n //= 10
    return rtn

n, s = 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))

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  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 = raw_input().split()
def msmdez(x,y):
	x,y = int(x),int(y)
	x1,y1 = str(x),str(y)
	if len(x1) == len(y1) != 1:
		if abs(x-y) < 10:
			return x1[-2] == y1[-2]
	return False
md = msmdez(n,s)
if int(n) <= int(s):
	print 0
	exit()
if int(n) < int(s) + sum(map(int,list(n))) and not md:
	print 0
	exit()
n,s = int(n),int(s)
if s < 10 :
	print n - 10 + 1
	exit()
if md:
	print 0
	exit()
S = s
while S <= n and not msmdez(S,n):
	k = S - sum(map(int,list(str(S))))
	if k >= s: break
	S+=10
if S - sum(map(int,list(str(S)))) < s and S+10 > n:
	print int(str(n)[-1]) + 1
	exit()
print n  - (S - int(str(S)[-1])) + 1

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
			#print(mid, self.isReallyBig(mid))
			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
		#print('resta', cp-add, cp, add)
		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 = map(int, input().split())
rbg = ReallyBigNumbers(n, s)
#print(rbg.x)
rbg.show()

# -*- coding: utf-8 -*-
n, s = 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)

R = lambda:map(int,raw_input().split())

n,s = R()

l,r = 1,n+1

while l<r:
    mid= (l+r)/2
    if mid - sum(map(int,list(str(mid)))) >= s:
	r=mid
    else:
	l=mid+1

print n-l+1

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

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)

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

def cal(x):
    tmp = x
    while x > 0:
        tmp -= x % 10
        x = x / 10
    return tmp

lo = 0
hi = n
res = -1
while lo <= hi:
    mid = (lo + hi) / 2
    if cal(mid) >= s:
        res = mid
        hi = mid - 1
    else:
        lo = mid + 1

if res == -1:
    print 0
else:
    print n - res + 1

n, s = map(int, raw_input().split())
ans = 0
for i in xrange(300):
    if s + i > n:
        break
    t = s + i - sum(map(int, str(s + i)))
    if t >= s:
        ans += 1
else:
    ans += n - s - 299
print ans

def add(n):
	res=0
	while n!=0:
		res+=n%10
		n/=10
	return res
n,s=map(int,raw_input().split())
l=1
r=n+1
while l<r:
	m=(l+r)/2
	if m-add(m)<s:
		l=m+1
	else:
		r=m
print n+1-(l+r)/2

from sys import stdin
n,s =  map(int,stdin.readline().split())
def d(m):
    cur = 0
    while m:
        cur += m%10
        m/=10
    return cur
lo = 1
hi = n
while hi > lo +  1:
    mid = (lo +  hi)/2
    if mid - d(mid) >=s:
        hi = mid
    else:
        lo = mid
while lo <=hi:
    if lo - d(lo)>=s:
        break
    lo += 1
print  max(n-lo+1,0)

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)
else:
    if j==n:
        if j-case(j)>=s:print(1)
        else:print(0)
    else:print(n-j+1)

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)

def solve(n, s):
    cur = -1
    i = s
    while i <= n:
        ds = sum(map(int, str(i)))
        if i - ds >= s:
            cur = i
            break
        i += 1
    if cur == -1:
        return 0
    return n - cur + 1

assert solve(12, 1) == 3
assert solve(25, 20) == 0
assert solve(10, 9) == 1
assert solve(1000000000000000000, 1000000000000000000) == 0

(n, s) = map(int, raw_input().split())
print solve(n, s)

n,s=map(int,raw_input().split())
l=0
u=10**22
def sod(n):
  st=str(n)
  v=0
  for i in st:
    v=v+int(i)
  return v

for i in range(1,200):
  m=(l+u)/2
  if m>=sod(m)+s:
    u=m
  else:
    l=m
  #print l,u,m
#print l,u
if sod(l)>=sod(l)+s:
  print max(n-l+1,0)
else:
  print max(n-u+1,0)

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)

#print(sum_digits(1))

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)

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

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

n,s = map(int,input().split())
cur = n - n%9
if(cur>=s):
    print(n%10+1)
else:
    print(0)

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): return sod(n)
	else: return 9*(nod(n)-1)
num=n-s
for i in range(s+1,min(s+maxsod(n),n)+1):
	if i-sod(i)<s:
		num-=1
print(num)

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): return sod(n)
	else: return 9*(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)

#a=[int(x) for x in input().split()]
#n=int(input())
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): return 9*(nod(n)-1)+n//10**(nod(n)-1)
	else: 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(i)
print(num)

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
print(ans + n - c + 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(y)
   print(max(n-a+1,0))
#   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))

if __name__ == "__main__":
    main()

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)])]
   a = y[0]
   print(max(n-a+1,0))
#   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))

if __name__ == "__main__":
    main()

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]*19
for i in range(18) :
    e=nine(18-i)
    l[i]=int(k/e)

    k-=l[i]*e
    if k==0 :
        break
    if i==17  or k%e>prosh(18-i-1) :

        l[i]+=1
        break
otv=0
for i in range(18) :

    otv+=10**(18-i)*l[i]

print(max(n-otv+1,0))

def nine(p) :

    s=''
    for i in range(p) :
        s+='9'
    return int(s)
n,k=map(int,input().split())
l=[0]*19
for i in range(18) :
    e=nine(18-i)
    l[i]=int(k/e)

    k-=l[i]*e
    if k==0 :
        break
    if i==17  or k%e>nine(18-i-1)*9 :

        l[i]+=1
        break
otv=0
for i in range(18) :

    otv+=10**(18-i)*l[i]
print(max(n-otv+1,0))

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]=int(k/e)

    k-=l[i]*e

    if k<=0 :

        break
    if i==17  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))

a = input()
a = a.split(' ')
a = list(map(int,a))
def really_big(n,s):
    if s >= n:
        return 0
    i = s + 1
    while True:
        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
print(really_big(a[0],a[1]))

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))<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
        else:
            if((mid+1-cal(mid+1))>=s):
                mid+=1
                break
            else:
                u=mid+1
    print(n-mid+1)

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)

if __name__ == "__main__":
    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 = (sl + 8) // 9 * 9
    x = multi(div(add(sl.copy(),[8]),9),9)
#    y = (x + 9) // 10 * 10
    y = multi(div(add(x.copy(),[9]),10),10)
#    z = y + (x - y + sum(y)) * 10 // 9
    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])

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

if __name__ == "__main__":
    input_str = input()
    n,s = [int(a) for a in input_str.split()]
    mod_res = s % 9
    div_res = s // 9
    x = (div_res + 1 if mod_res else div_res) * 9
    ans = n - x if n -x > 0 else 0
    print(ans)

if __name__ == "__main__":
    input_str = input()
    n,s = [int(a) for a in input_str.split()]
    mod_res = s % 9
    div_res = s // 9
    x = (div_res + 1 if mod_res else div_res) * 9
    y = (x + 9) // 10 * 10
    ans = n - y + 1 if n - y + 1 > 0 else 0
    print(ans)

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)

if __name__ == "__main__":
    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 = (sl + 8) // 9 * 9
    x = multi(div(add(sl.copy(),[8]),9),9)
#    y = (x + 9) // 10 * 10
    y = multi(div(add(x.copy(),[9]),10),10)
#    z = y + (x - y + sum(y)) * 10 // 9
    sumy = list([int(a) for a in list(str(sum(y)))])
    sumy.reverse()
    z = add(y,multi(div(minus(minus(x,y),sumy),9),10))
    if cmp(nl,z):
        ans = add(minus(nl,z),[1])
    else:
        ans = [0]
    ans.reverse()
    ansstr = [str(a) for a in ans]
    print("".join(ansstr))

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

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

count = 0
summ = sum_digits(n)
# print(summ)
for num in range(n, 9, -1):
	# value = num - s
	if num - summ  >= s:
		count += 1
	if (num - s) % 10 == 0:
		summ = sum_digits(num)
	else:
		summ -= 1

	# print(summ)

# for num in range(10):
# 	if num - s

print(count)

# for num in range(n+1):

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

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

count = 0
summ = sum_digits(n)
# print(summ)
for num in range(n, 8, -1):
	# value = num - s
	if num - summ  >= s:
		count += 1
	if (num - s) % 10 == 0:
		summ = sum_digits(num)
	else:
		summ -= 1

	# print(summ)

# for num in range(10):
# 	if num - s

print(count)

# for num in range(n+1):

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

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

# count = 0
# summ = sum_digits(n)
# # k = sum_digits(n - n%10 - 1)
# # print(k)
# for num in range(n, 9, -1):
# 	if num % 10 == 9:
# 		summ = sum_digits(num)
# 	# print(num, summ)
# 	if num - summ  >= s:
# 		count += 1
# 	summ -= 1

# print(count)

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): #s >= elem and s1 < elem or
		# print(l,medium,r)
		if s <= elem:
			l = medium
		elif s >= elem:
			r = medium
		k = medium
		medium = (l + r ) // 2
		if k == medium:
			break
		# print(l,medium,r)
		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 = map(int, input().split())
# a = [i for i in range(n+1)]

y = binsearch( 0, n, s)
# print(y)
print(n - y + 1)

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

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

count = 0
summ = sum_digits(n)
# print(summ)
for num in range(n, 9, -1):
	# value = num - s
	if (num - s) % 10 == 0:
		summ = sum_digits(num)
	else:
		summ -= 1
	if num - summ  >= s:
		count += 1
	# print(summ)

# for num in range(10):
# 	if num - s
c = 1

print( count)

# for num in range(n+1):

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

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

count = 0
summ = sum_digits(n)
# print(summ)
for num in range(n, 9, -1):
	# value = num - s
	if (num - s) % 10 == 0:
		summ = sum_digits(num)
	else:
		summ -= 1
	if num - summ  >= s:
		count += 1
	# print(summ)

# for num in range(10):
# 	if num - s

print( count)

# for num in range(n+1):

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

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

count = 0
summ = sum_digits(n)
k = sum_digits(n - n%10 - 1)
print(k)
for num in range(n, 9, -1):
	if num % 10 == 9:
		summ = sum_digits(num)
	print(num, summ)
	if num - summ  >= s:
		count += 1
	summ -= 1

print(count)

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

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

count = 0
summ = sum_digits(n)
# print(summ)
for num in range(n, 9, -1):
	# value = num - s
	if (num - s) % 10 == 0:
		summ = sum_digits(num)
	# print(num, summ)
	if num - summ  >= s:
		count += 1
	summ -= 1

	# print(summ)

# for num in range(10):
# 	if num - s

print(count)

# for num in range(n+1):

n, s= map(int, input().split())
counter=0
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)

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  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])
for i in range(1, n+1):
    if(sum_of_its_digits(i, s)):
        sum=n-i+1
        break
print(sum)

for _ in range(1):
    n,s=map(int,input().split())
    #l=[int(i) for i in input().split()]
    lo=1
    hi=n
    ans=n
    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)

n, q = map(int, input().split())
p = []
s = q
while s > 8:
    t = 0
    while (t + 1) * 10 - 1 <= s:
        t = (t + 1) * 10 - 1
    p.append((s // t, t + 1))
    s %= t
if s > 0:
    if p != []:
        start = p[0][0] + 1
    else:
        start = 1
    while start <= q:
        start *= 10
    print(max(0, n - start + 1))
else:
    F = True
    for i in p:
        if i[0] > 9:
            F = False
    if not F:
        start = p[0] + 1
        while start <= q:
            start *= 10
        print(max(0, n - start + 1))
    else:
        start = sum(p[i][0] * p[i][1] for i in range(len(p)))
        print(max(n - start + 1, 0))

n, q = map(int, input().split())
p = []
s = q
while s > 8:
    t = 0
    while (t + 1) * 10 - 1 <= s:
        t = (t + 1) * 10 - 1
    p.append((s // t, t + 1))
    s %= t
if s > 0:
    if p != []:
        start = p[0][0] + 1
    else:
        start = 1
    while start <= q:
        start *= 10
    print(max(0, n - start + 1))
else:
    F = True
    for i in p:
        if i[0] > 9:
            F = False
    if not F:
        start = p[0][0] + 1
        while start <= q:
            start *= 10
        print(max(0, n - start + 1))
    else:
        start = sum(p[i][0] * p[i][1] for i in range(len(p)))
        print(max(n - start + 1, 0))

def calc(n):
	val = n
	cnt = 0
	while(val):
		cnt += val%10
		val//=10
	return n-cnt

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

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

mod=1000000007

import math

def main():

    n,s=mi()
    lo=1
    hi=1000000000000000000
    while(lo<hi):
        mid=(lo+hi)//2
        #print(mid)
        a=mid-su(mid)
        if a>s:
            hi=mid-1
        elif a<s:
            lo=mid+1
        else:
            break
    if mid-su(mid)<s:
        c=int(math.ceil(mid/10))
        print(max(0,n-c*10+1))
        exit()
    c=mid//10
    print(max(0,n-c*10+1))

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

def main():

    n,s=mi()
    a=int(math.ceil(s/9))
    d=int(math.log10(n))
    if a%10==1:
        e=10*(d-2)+1
        a-=e
    #print(d)
    c=10*a
    #print(a,c)
    ans=n-c+1
    if ans<0:
        ans=0
    print(ans)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

def main():

    n,s=mi()
    a=int(math.ceil(s/9))
    c=10*a
    ans=n-c+1
    if ans<0:
        ans=0
    print(ans)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

mod=1000000007

import math

def main():

    n,s=mi()
    lo=1
    hi=1000000000000000000
    while(lo<hi):
        mid=(lo+hi)//2
        #print(mid)
        a=mid-su(mid)
        if a>s:
            hi=mid-1
        elif a<s:
            lo=mid+1
        else:
            break
    if mid-su(mid)<s:
        c=int(math.ceil(mid/10))
        print(max(0,n-c*10-1))
        exit()
    c=mid//10
    ans=c*10
    print(n-ans+1)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

def main():

    n,s=mi()
    a=int(math.ceil(s/9))
    d=int(math.log10(n))
    if a%10==1 and a>1:
        e=10*(d-2)+1
        a-=e
    #print(d)
    c=10*a
    #print(a,c)
    ans=n-c+1
    if ans<0:
        ans=0
    print(ans)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

def main():

    n,s=mi()
    a=int(math.ceil(s/9))
    d=int(math.log10(n))
    if d>=2:
        e=10*(d-2)+1
        a-=e
    #print(d)
    c=10*a
    #print(a,c)
    ans=n-c+1
    if ans<0:
        ans=0
    print(ans)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

"""
// Author : snape_here - Susanta Mukherjee

"""

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

mod=1000000007

import math

def main():

    n,s=mi()
    lo=1
    hi=1000000000000000000
    while(lo<hi):
        mid=(lo+hi)//2
        #print(mid)
        a=mid-su(mid)
        if a>s:
            hi=mid-1
        elif a<s:
            lo=mid+1
        else:
            break
    c=mid//10
    ans=c*10
    print(n-ans+1)

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()

n,s = map(int,raw_input().split())
ans = 0
for i in xrange(s,min(s+1000,n+1)):
  if i-sum([int(x) for x in list(str(i))]) < s:
    ans += 1
print n+1-s-ans

N,S = map(int,raw_input().split())
ans = 0
for i in range(S,min(S+10000,N+1)):
    if i-sum([int(x) for x in str(i)])>=S:
        ans += 1
print ans

R = lambda:map(int,raw_input().split())

n,s = R()

f = s/9
if 9*f<s:
    f+=1
l = f*10

if l <=n :
    print n-l+1
else :
    print 0

R = lambda:map(int,raw_input().split())

n,s = R()

l,r = 10,n+1

while l<r:
    mid= (l+r)/2
    if mid - sum(map(int,list(str(mid)))) >= s:
	r=mid
    else:
	l=mid+1

print n-l+1

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

num = ''
div = 9

if s//10 != 0:
    div= int('9'*(len(str(s))-1))
    while s:
        num += str(s//div)
        s = s%div
        div //= 10
        if div == 0:
            div = 1
        if s == 0:
            num += '0'
else:
    num = str(s)
mini = int(num)
if mini%10 != 0:
    mini += 10
    mini -= mini%10

print(max(0, n-mini+1))

# while s:
#     num += str(s%div)
#     s = s//div
#     div = div*10+9

# num = num[::-1]

# print(max(0, n-mini+1))

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

num = ''
div = 9

if s//10 != 0:
    div= int('9'*(len(str(s))-1))
    while s:
        num += str(s//div)
        s = s%div
        div //= 10
        if div == 0:
            num += str(s)
            break
        elif s == 0:
            num += '0'
            break
else:
    num = str(s)
mini = int(num)
if mini%10 != 0:
    mini += 10
    mini -= mini%10

print(max(0, n-mini+1))

# while s:
#     num += str(s%div)
#     s = s//div
#     div = div*10+9

# num = num[::-1]

# print(max(0, n-mini+1))

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

num = ''
div = 9

if s//10 != 0:

    div= int('9'*(len(str(s))-1))
    if int('9'*len(str(s))) == s:
        div = s
    while div:
        num += str(s//div)
        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))

# while s:
#     num += str(s%div)
#     s = s//div
#     div = div*10+9

# num = num[::-1]

# print(max(0, n-mini+1))

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

num = ''
div = 9

if s//10 != 0:
    div= int('9'*(len(str(s))-1))
    while s:
        num += str(s//div)
        s = s%div
        div //= 10
        if div == 0:
            div = 1
else:
    num = str(s)
mini = int(num)
if mini%10 != 0:
    mini += 10
    mini -= mini%10

print(max(0, n-mini+1))

# while s:
#     num += str(s%div)
#     s = s//div
#     div = div*10+9

# num = num[::-1]

# print(max(0, n-mini+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
    if div > s:
        num = '1' + '0'*len(str(div))
    else:
        while div:
            num += str(s//div)
            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))

# while s:
#     num += str(s%div)
#     s = s//div
#     div = div*10+9

# num = num[::-1]

# print(max(0, n-mini+1))

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

num = ''
while s:
    num += str(s%9)
    s = s//9

num = num[::-1]

mini = int(num)
if mini%10 != 0:
    mini += 10
    mini -= mini%10
print(max(0, n-mini+1))

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:
    print(0)
else:
    print(n-cur+1)

import sys

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

ok, ng = 10**18, -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))

# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-19 14:49
# @url:https://codeforc.es/contest/817/problem/C
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

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")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
## 精度 print("%.10f" % ans)
## sqrt:int(math.sqrt(n))+1
## 字符串拼接不要用+操作，会超时
## 二进制转换:bin(1)[2:].rjust(32,'0')
## array copy:cur=array[::]
## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200
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)]
    # print (weight,digit)
    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:
                ans=0
                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)
    # print (mn)
    if mn>n:
        print (0)
    else:
        print (n-mn+1)

if __name__ == "__main__":
    main()

# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-19 14:49
# @url:https://codeforc.es/contest/817/problem/C
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

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")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
## 精度 print("%.10f" % ans)
## sqrt:int(math.sqrt(n))+1
## 字符串拼接不要用+操作，会超时
## 二进制转换:bin(1)[2:].rjust(32,'0')
## array copy:cur=array[::]
## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200
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)]
    # print (weight)
    res=[0]*len(digit)
    mn=0
    for i in range(len(digit)-1,-1,-1):
        t=math.ceil(s/weight[i])
        mx=digit[i] if i==len(digit)-1 else 9
        if t>mx:
            break
        s=s-t*weight[i]
        res[i]=t
        mn+=t*10**(i+1)
    # print (res,mn)
    if mn==0:
        print (0)
    else:
        print (n-mn+1)

if __name__ == "__main__":
    main()

# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-19 14:49
# @url:https://codeforc.es/contest/817/problem/C
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

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")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
## 精度 print("%.10f" % ans)
## sqrt:int(math.sqrt(n))+1
## 字符串拼接不要用+操作，会超时
## 二进制转换:bin(1)[2:].rjust(32,'0')
## array copy:cur=array[::]
## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200
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)]
    # print (weight)
    res=[0]*len(digit)
    mn=0
    for i in range(len(digit)-1,-1,-1):
        t=math.floor(s/weight[i])
        mx=digit[i] if i==len(digit)-1 else 9
        if t>mx:
            break
        s=s-t*weight[i]
        res[i]=t
        mn+=t*10**(i+1)
    # print (res,mn,s)
    mn=10*math.ceil(s/9)+mn
    if mn>n:
        print (0)
    else:
        print (n-mn+1)

if __name__ == "__main__":
    main()

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)
print(z)
print(count)
print(digit_safe(z))
while z < z1 and count < s:
    z += digit_safe(s-count)
    count = diff(z)
if z <= z1:
    res += (z1-z)
print(res)

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

        # print(n-sum([int(x) for x in str(n)])>s)
        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(start,mid,end)
    print(n-end+1)

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

n, s = map(int, input().split())
su = suma(n)
res = 0
maxS = n - su
if maxS >= s:
	res += (n % 10) + 1
#print('ms', maxS)
#print('res p:', res)
maxS -= 9
#print('mS', maxS)
cant = max(0,(maxS // 9) - s)
res += cant * 10
print(res)

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

n, s = map(int, input().split())
if s > n:
	print(0)
else:
	su = suma(n)
	res = 0
	maxS = n - su
	if maxS >= s:
		res += (n % 10) + 1
	#print('ms', maxS)
	#print('res p:', res)
	maxS -= 9
	#print('mS', maxS)
	while maxS >= s:
		res += 10
		maxS -= 9
	print(res)

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

n, s = map(int, input().split())
su = suma(n)
res = 0
maxS = n - su
if maxS >= s:
	res += (n % 10) + 1
#print('ms', maxS)
#print('res p:', res)
maxS -= 9
#print('mS', maxS)
cant = max(0, ((maxS // 9) - ((s - 1) // 9)))
res += cant * 10
print(res)

class ReallyBigNumbers:

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

	def binarySearch(self):
		l = s
		h = 10e18
		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 = map(int, input().split())
rbg = ReallyBigNumbers(n, s)
rbg.show()

from sys import stdin
def di(n):
 ans = 0
 while n:
  ans += n%10
  n/=10
 return ans
n,s = map(int,stdin.readline().split())
ans = 0
my = set()
if s< 180:
 for tt in xrange(1,180):
  for ss in xrange(s,180):
   hi = min(n, tt+ s)
   for i in xrange(ss,hi+1):
    if i-di(i) == ss:
     my.add(i)
print len(my)

n, s = map(int, raw_input().split())
ans = 0
for i in xrange(300):
    if s + i > n:
        break
    t = s + i - sum(map(int, str(s + i)))
    if t >= s:
        ans += 1
else:
    ans += n - s - 300
print ans

def check(x):
    temp = str(x)
    ans = 0
    for n in temp:
        ans += int(n)
    return x-ans

n,s = map(int,raw_input().strip().split())
if check(n)<s:
    print 0
elif s==0:
    print n
else:
    temp = s/9
    hund = (temp+1)/11
    tens = (temp+1)%11
    ans = 0
    #print temp,hund,tens,ans
    if hund:
        ans = hund*100
    #print ans
    if tens:
        ans += tens*10-1
    if s%9==0:
        ans -= 10
    print max(n-ans,0)

n,m=map(int,raw_input().split())
l=1
r=n
def c(a):
    p=0
    a1=a
    while a1!=0:
        p=p+a1%10
        a1=a1/10
    return a-p

while l<r:
    mid=(l+r)/2
    if c(mid)<=m:
        l=mid+1
    else:
        r=mid
print n-l+1 if c(l)>=m else 0

import sys
def F(i):
	return (i - sum([int(j) for j in str(i)]))
n,s=map(int,raw_input().split())
l=1
h=n
while(l<h):
	mid=l+(h-l)//2
	if(F(mid) < s and F(mid+1) >= s):
		print n-mid
		sys.exit()
	elif(F(mid) < s):
		l=mid+1
	else:
		h=mid-1
print 0

import sys
def F(i):
	return (i - sum([int(j) for j in str(i)]))
n,s=map(int,raw_input().split())
l=1
h=n
mid=0
b=1
while(l<h):
	mid=l+(h-l)/2
	# print mid
	if(F(mid) < s and F(mid+1) >= s):
		# print n-mid
		b=0
		break
	elif(F(mid) < s):
		l=mid+1
	else:
		h=mid-1
if(b):
	print n-mid-1
else:
	print n-mid

import sys
def F(i):
	return (i - sum([int(j) for j in str(i)]))
n,s=map(int,raw_input().split())
l=1
h=n
mid=0
b=1
while(l<h):
	mid=l+(h-l)/2
	# print mid
	if(F(mid) < s and (mid+1 <= n and F(mid+1) >= s)):
		# print n-mid
		b=0
		break
	elif(F(mid) < s):
		l=mid+1
	else:
		h=mid-1
if(b):
	print n-mid-1
else:
	print n-mid

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

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

num = s + 1
answer = 0

while num <= n:
	if num == n and num - sum(num) >= s:
		answer += 1
		break
	if num - sum(num) >= s and num - sum(num) < 133:
		if n >= num - num%10 + 10:
			answer += 10
			num = num - num%10 + 10
		else:
			answer += num %10 + n - num + 1
			num = n

	elif num - sum(num) >= s and num - sum(num) > 133:
		answer += n - num
		num = n

	else:
		num = num - num%10 + 10

print answer

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

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

num = s + 1
answer = 0

if num == n and num - sum(num) >= s:
	answer += 1

while num <= n:
	if num == n:
		break
	if num - sum(num) >= s and num - sum(num) < 133:
		if n >= num - num%10 + 10:
			answer += 10
			num = num - num%10 + 10
		else:
			answer += num %10 + n - num + 1
			num = n

	elif num - sum(num) >= s and num - sum(num) > 133:
		answer += n - num
		num = n

	else:
		num = num - num%10 + 10

print answer

n , k = map(int, raw_input().split())

def sum(k):
	s = 0
	while k > 0:
		s += k%10
		k /= 10
	return s

t = k
while t <= n:
	d = t - sum(t)
	if d >= k:
		break
	t += 1

print n - t + 1

n,s = raw_input().split()
def msmdez(x,y):
	x,y = int(x),int(y)
	x1,y1 = str(x),str(y)
	if len(x1) == len(y1) != 1:
		if abs(x-y) < 10:
			return x1[-2] == y1[-2]
	return False
md = msmdez(n,s)
if int(n) <= int(s):
	print 0
	exit()
if int(n) < int(s) + sum(map(int,list(n))) and not md:
	print 0
	exit()
n,s = int(n),int(s)
if s < 10 :
	print n - 10 + 1
	exit()

if md or msmdez(s + 10, n):
	print 0
	exit()
S = s
while S <= n and not msmdez(S,n):
	k = S - sum(map(int,list(str(S))))
	if k >= s: break
	S+=10
if S+10 > n:
	print int(str(n)[-1]) + 1
	exit()
print n  - (S - int(str(S)[-1])) + 1

n,s = raw_input().split()
def msmdez(x,y):
	x,y = int(x),int(y)
	x1,y1 = str(x),str(y)
	if len(x1) == len(y1) != 1:
		if abs(x-y) < 10:
			return x1[-2] == y1[-2]
	return False
md = msmdez(n,s)
if int(n) <= int(s):
	print 0
	exit()
if int(n) < int(s) + sum(map(int,list(n))) and not md:
	print 0
	exit()
n,s = int(n),int(s)
if s < 10 :
	print n - 10 + 1
	exit()
if md:
	print 0
	exit()
S = s
while S <= n and not msmdez(S,n):
	k = S - sum(map(int,list(str(S))))
	if k >= s: break
	S+=10
if S+10 > n:
	print int(str(n)[-1]) + 1
	exit()
print n  - (S - int(str(S)[-1])) + 1

n,s = raw_input().split()
def msmdez(x,y):
	x,y = int(x),int(y)
	x1,y1 = str(x),str(y)
	if len(x1) == len(y1) != 1:
		if abs(x-y) < 10:
			return x1[-2] == y1[-2]
	return False
md = msmdez(n,s)
if int(n) <= int(s):
	print 0
	exit()
if int(n) < int(s) + sum(map(int,list(s))) and not md:
	print 0
	exit()
n,s = int(n),int(s)
if s < 10 :
	print n - 10 + 1
	exit()
if md or msmdez(s + 10, n):
	print 0
	exit()
S = s
while S <= n and not msmdez(S,n):
	k = S - sum(map(int,list(str(S))))
	if k >= s: break
	S+=10
if S+10 > n:
	print int(str(n)[-1]) + 1
	exit()
print S
print n  - (S - int(str(S)[-1])) + 1

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

d = ((s-1)/9 + 1) * 10
if n < d: print 0
else: print n - d + 1

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

def cal(x):
    tmp = x
    while x > 0:
        tmp -= x % 10
        x = x / 10
    return tmp

lo = 0
hi = n
res = -1
while lo <= hi:
    mid = (lo + hi) / 2
    if cal(mid) >= s:
        res = mid
        hi = mid - 1
    else:
        lo = mid + 1

print res
if res == -1:
    print 0
else:
    print n - res + 1

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

def dif(x):
    tmp = x
    while tmp > 0:
        x = x - tmp % 10
        tmp = tmp/10
    return x

l = 0
r = 1000000000000000000
while l < r:
    m = (l + r)/2
    if dif(m) < s:
        l = m + 1
    else: r = m
d = l
while d % 10 > 0: d -= 1
if n < d: print 0
else: print n - d + 1

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

def dif(x):
    tmp = x
    while tmp > 0:
        x = x - tmp % 10
        tmp = tmp/10
    return x

l = 0
r = 1000000000000000000
while l < r:
    m = (l + r)/2
    if dif(m) < s:
        l = m + 1
    else: r = m
d = l
if n < d: print 0
else: print n - d + 1

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

def dif(x):
    tmp = x
    while tmp > 0:
        x = x - tmp % 10
        tmp = tmp/10
    return x

l = 0
r = 1000000000000000000
while l < r:
    m = (l + r)/2
    if dif(m) < s:
        l = m + 1
    else: r = m - 1
d = l
if n < d: print 0
else: print n - d + 1

import re

def get_index(s):
	l = []
	for x in range(0,len(s)):
		if s[x]=='b':
			l.append(x)
	return l
def gen(nums):
	if(nums[1]%9 ==0):
		ans = (nums[0]-(int(nums[1]/9)*10) +1 )
		return ans if ans>0 else 0
	ans = (nums[0]-(int(nums[1]/9)*10 + 10) + 1)
	return ans if ans>0 else 0

def main():
	nums = raw_input().split(' ')
	nums = map(lambda x:int(x),nums)

	print gen(nums)

if __name__ == "__main__":
	# while True:
	# 	main()
	main()

from math import ceil
n, s = [int(i) for i in input().split()]
k = ceil(s/9)
f = 10 * k
print(max(n - f + 1, 0))

from math import ceil
n, s = [int(i) for i in input().split()]
k = s // 9 if s % 9 == 0 else (s//9 + 1)
f = 10 * k
print(max(n - f + 1, 0))

n, s = map(int, input().rstrip().split())
if n <= s:
    print(0)
    exit()
x = s // 9
rem = s % 9
if rem > 0:
    x += 1
print(max(0, n - (x * 10) + 1))

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:
		#print((l+u)//2)
		return (l+u)//2
	if (((l+u)//2) + 1 - sumOfDigits(((l+u)//2)+1)) < s:
		#print((l+u)//2)
		return binSearch(s, ((l+u)//2)+1, u)

n, s = input().strip().split(' ')
s = int(s)
# print(sumOfDigits(int(n)))
if int(n) - sumOfDigits(n)<s:
	print(0)
else:
	d = binSearch(s, 1, int(n))
	# print(d)
	# while d-sumOfDigits(d) >= s:
	# 	e = str(d)
	# 	d = d - int(e[len(e)-1]) - 1
	print(int(n) - d)

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