N = int(input())
K = int(input())

def count_K_naive(N, K):
    def count_nonzero(n):
        num_nonzero = 0
        while n > 0:
            if n % 10 != 0:
                num_nonzero += 1
            n = n // 10
        return num_nonzero

    num_K = 0
    for n in range(1, N+1):
        if count_nonzero(n) == K:
            num_K += 1

    return num_K

print(count_K_naive(N, K))
