import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

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 main():
    n = II()
    k = II()
    keta = []
    l = n
    while True:
        amari = l % 10
        keta.append(amari)
        l = l // 10
        if l < 1:
            break

    if len(keta) < k:
        print(0)
        return

    ans = 0
    for i in range(1, len(keta)):
        if i < k:
            continue
        ans += cmb(i - 1, k - 1) * pow(9, k)
    ans += cmb(len(keta) - 1, k - 1) * pow(9, k-1) * (keta[-1] - 1)
    # print(ans)
    if k == 1:
        print(ans + 1)
    elif k == 2:
        for i in range(len(keta)-1):
            if sum(keta[i+1:-1]) == 0:
                ans += keta[i]
            else:
                ans += 9
        print(ans)

    else:
        for i in range(len(keta)-1):
            for j in range(i+1, len(keta)-1):
                if sum(keta[j+1:-1]) == 0:
                    ans += (max(keta[j]-1, 0)) * 9
                    if sum(keta[i+1:j]) == 0:
                        ans += keta[i]
                    else:
                        ans += 9
                else:
                    ans += 81

        print(ans)


if __name__ == '__main__':
    main()