import sys
import itertools as it

n = int(input())
k = int(input())
if k == 2 and n < 11:
    print(0)
    sys.exit()
elif k == 3 and n < 111:
    print(0)
    sys.eixt()

nl = list(map(int, list(str(n))))
keta = len(nl)

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


if keta == 1:
    print(n)
    sys.exit()
if keta > k:
    a0 = cmb(keta - 1, k) * 9 ** k
else:
    a0 = 0
print(a0)

nl0 = nl.pop(0)
a1 = 0
if k == 1:
    a1 = nl0
else:
    if k == 2:
        a1 = sum(nl)
        a1 += (nl0 - 1) * 9 * (keta - 1)
    elif k == 3:
        for i in it.combinations(nl, 2):
            a1 += i[0] * i[1]a
        a1 += (nl0 - 1) * cmb(keta - 1, 2) * 9 ** 2
print(a0 + a1)
