#E

n = int(input())
k = int(input())
count = 0
for i in range(1,n+1):
    
    m = 0
    s = str(i)
    for j in range(len(s)):
        
        if s[j] != "0":
            m += 1
    
    if m == k:
        count += 1
    
print(count)