import itertools

def read():
    N = str(input().strip())
    K = int(input().strip())
    return N, K

def nCk(n, k):
    return len(list(itertools.combinations(range(n), k)))

def solve(N, K):
    L = len(N)
    count = 0
    factor = [1, 9**1, 9**2, 9**3]
    nonzero_counts = [len(str(i)) - str(i).count('0') for i in range(1000)]
    for d in range(L):
        if d == 0:
            if K >= 1:
                for i in range(1, int(N[0:1])):
                    count += (K-nonzero_counts[i]) * factor[K-1]
            if K >= 2:
                for i in range(10, int(N[0:2])):
                    count += (K-nonzero_counts[i]) * factor[K-2]
            if K >= 3:
                for i in range(100, int(N[0:3])):
                    count += (K-nonzero_counts[i]) * factor[K-3]
            count += 1
        else:
            # [0][1-9][0]*[1-9][0]*[1-9][0]*
            count += nCk(L-d-1, K-1) * factor[K]
    return count


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))
