n = int(input())
k = int(input())
ans = list()
notans = list()
for i in range(1, n+1):
    if len(str(i)) == k:
        ans.append(i)
    if ("0" in str(i) and len(str(i)) == k):
        notans.append(i)
print(len([elem for elem in ans if elem not in notans ]))