n = int(input())
k = int(input())
res = 0

for i in range(n + 1):
    point = list(filter(lambda x: x != 0 ,(list(map(int, str(i))))))
    #point = [m for m in point if m != 0]
    #print(point)
    if len(point) == k:
        res += 1
        
print(res)