def main():
    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 10**3):
        fact.append(fact[-1]*i % mod)

    def inv_n(n):
        return pow(n, mod-2, mod)

    def nCr(n, r, mod=10**9+7):
        return inv_n(fact[n-r]*fact[r] % mod)*fact[n] % mod

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

    ans = 0
    m = len(n)
    if len(n) < 5:
        n = int(n)
        for i in range(1, n+1):
            i = str(i)
            if len(i)-i.count("0") == k:
                ans += 1
        print(ans)
        return
    for i in range(k):
        ans += nCr(m-i-1, k-i)*pow(9, k-i)
        ans += (int(n[i])-1)*nCr(m-i-1, k-i-1)*pow(9, k-i-1)

    print(ans+1)


main()