from operator import mul
from functools import reduce


def comb(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


s = input()
d = len(s)
m = int(s[0])
k = int(input())
a = 9**k * comb(d - 1, k)
if k == 1:
    a += m
elif k == 2:
    a += (m - 1) * 9 * max(d - 1, 0)
    for di, si in enumerate(s[1:]):
        if int(si) > 0:
            a += 9 * (d - di - 2)
            a += int(si)
            break
elif k == 3:
    a += (m - 1) * 9 * 9 * comb(d - 1, 2)
    for di, si in enumerate(s[1:]):
        if int(si) > 0:
            a += 9 * 9 * comb(d - di - 2, 2)
            a += int(si) * 9 * (d - di - 2)
            break
print(a)