n = int(input())
k = int(input())
l = []
b = 0
o = []

for i in range(1,n+1):
    for j in range(len(str(i))):
        if str(i)[j] != '0':
            b += 1
    l.append(b)
    b = 0
    
for m in range(n):
    if l[m] == k:
        o.append(m)
        
print(len(o))