import math

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


def func(n, k):
    strn = str(n)
    lenn = len(strn)
    ret = cmb(lenn, k) * 9 ** k
    for x in [9 - int(c) for c in strn]:
        k -= 1
        y = cmb(lenn - 1, k)
        ret -= x * 9 ** k * y
        if k == 0:
            break

    return ret
N = int(input())
K = int(input())

print(func(N, K))