N=int(input())
K=int(input())
an_cnt=0
for i in range(N+1):
    cnt=0
    moji=list(str(i))
    for m in moji:
        if m!='0':
            cnt+=1
    if cnt==K:
        
        an_cnt+=1
print(an_cnt)
