p=[input() for i in range(2)]
N=int(p[0])
K=int(p[1])
cnt=0
for a in range(N):
    a+=1
    a=str(a)
    a=list(a)
    a=[int(s) for s in a]
    cnt2=(len(a))-(a.count(0))
    if cnt2==K:
        cnt+=1
print(cnt)