N=int(input())
K=int(input())

def CountNotZero(n):
    NotZero=0
    while n>0:
        if (n%10)!=0:
            NotZero+=1
        n=int(n/10)  
    return NotZero

def main(n,k):
    answer=0
    while n>0: 
        if CountNotZero(n)==k:
            answer+=1
        n-=1
    return answer

print(main(N,K))