
# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


def func1(keta, not_0):
    return cmb(keta, not_0) * (9**not_0)

def solve(keta, not_0, max_num):

    if keta < not_0 or keta <= 0:
        return 0
    ans = 0

    if int(max_num[-keta]) >= 2 and keta-1 >= 0 and not_0-1 >= 0:
        ans += (int(max_num[-keta]) - 1) * func1(keta-1, not_0-1)
    if keta-1 >= not_0 and keta-1 >= 0 and not_0 >= 0:
        ans += func1(keta-1, not_0)
    if not_0 >= 1:
        ans += solve(keta-1, not_0-1, max_num)
    return ans


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

n_len = len(n_str)

print(solve(n_len, k, n_str))
