N = int(input())
K = int(input())
list_N = []
for i in range(N):
    list_N.append(str(i+1))
list_N_n=[]
count=0
for i in range(len(list_N)):
    a=0
    for j in range(len(list_N[i])):
        if not list_N[i][j]=="0":
            a+=1
    if a == K:
        count+=1
print(count)