n = int(input())
k = int(input())
total = 0
for i in range(1,n+1):
    j = i
    t = 0
    while j!=0:
        if j%10 != 0:
            t+=1
        j//=10
    if t == k:
        total+=1
print(total)
