n = int(input())
k = int(input())
start = int('1'*k)
i = start
inc = 10**(k-1)
x = 1
r = 0
lst = []
while i <= n:
    lst.append(i)
    i += inc
    x += 1
    if x == 10:
        x = 0
        inc = 10**(k-r)
        r -= 1
print(len(lst))