import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def binomial_coefficient(n, r, mod=10**9+7):
    """
    二項係数nCr, (n,r)をmodで除したあまりを返す
    """
    res = 1
    div = 1
    r = min(r, n - r)
    for i in range(r):
        res *= (n - i) % mod
        div *= (i + 1) % mod
    res *= pow(div, mod - 2, mod)
    return res % mod


def calc(N, K):
    if K == 0:
        return 1
    if K > len(N):
        return 0

    res = 0
    # 一番上が0の時

    if len(N)-1 > K:
        res += binomial_coefficient(len(N) - 1, K) * (9 ** K)

    # 一番上が1~N[0]-1の時
    res += (int(N[0]) - 1) * (9**(K-1)) * binomial_coefficient(len(N)-1, K-1)

    # 一番上がN[0]のとき
    res += calc(N[1:], K-1)

    return res


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    d = len(str(N))
    N = str(N)
    ans = calc(N, K)
    print(ans)
