n = int(input())
k = int(input())
c = 0
for i in range(1, n+1):
    s = str(i)
    if '0' in s:
        num = s.count('0')
        if len(s)-num == k:
            c+=1
    else :
        if len(s) == k:
            c+=1
print(c)