N = int(input())
K = int(input())
ans = 0
for i in range(1,N+1):
    number = []
    for j in str(i):
        number.append(j)
    new = [s for s in number if s != "0"]
    if len(new) == K:
        ans += 1
    else:
        pass
print(ans)