n = int(input())
k = int(input())

def solve(n,k):
    if n<10**5:
        ans=0
        for num in range(1,n+1):
            cnt=0
            for char in str(num):
                if char!="0":
                    cnt+=1
            if cnt==k:
                ans+=1
        return ans

print(solve(n,k))