from scipy.special import comb
from itertools import combinations
N = int(input())
K = int(input())

if len(str(N)) < K:
    print(0)
    exit()
l = len(str(N))
ans = 0
for i in range(1, l):
    if i < K:
        continue
    if i == K:
        ans += 9 ** K
    else:
        ans += comb(i-1, K-1, exact=True) * (9 ** K)
N_str = list(str(N))

keta = l
num = [i for i in range(1, keta)]
if K == 1:
    ans += int(N_str[0])
else:
    ans += comb(keta-1, K-1, exact=True) * (9 ** (K-1)) * (int(N_str[0]) - 1)
    for v in combinations(num, K-1):
        add = 1
        for j in v:
            add *= int(N_str[j])
        ans += add
print(ans)