import bisect
import math


def perm(n, r):
    if n < r:
        return 0
    return math.factorial(n) // math.factorial(n - r)


def comb(n, r):
    return perm(n, r) // math.factorial(r)


def gen_A():
    A = []
    n = 1
    while n <= 10 ** 100:
        for i in range(1, 10):
            A.append(n * i)
        n *= 10
    return A


N = int(input())
K = int(input())
A = gen_A()
I = bisect.bisect(A, N)
ans = 0
for a in A[: I - 1]:
    length = len(str(a))
    if length >= K:
        ans += comb(length - 1, K - 1) * 9 ** (K - 1)

str_N = str(N)
if len(str_N) >= K:
    if K == 1:
        ans += 1
    if K == 2:
        ans += int(str_N[1])
        for _ in range(len(str_N) - 2):
            ans += 9
    if K == 3:
        ans += int(str_N[1]) * (len(str_N) - 2) * 9
        ans += comb(len(str_N) - 2, 2) * 9 ** 2


print(ans)
