import math
import itertools

str_N = input()
K = int(input())
N = int(str_N)
zero_num = len(str_N)-K

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count():
    c = 0
    top = int(str_N[0])
    if K==3:
        for one in itertools.combinations(list(range(1,len(str_N))), K-1):
            a,b = one
            if a==1:
                if int(str_N[a])==0:
                    c+=0
                else:
                    c += (top-1)*int(str_N[a])*9+(int(str_N[a])-1)*9+int(str_N[b])
            else:
                c += top*9*9
            
    elif K==2:
        for one in range(1, len(str_N)):
            if one==1:
                c += (top-1)*9+int(str_N[one])
            else:
                c += top*9
    elif K==1:
        c+=top
    return c

ans = 0
if len(str_N)<K:
    ans = 0
elif len(str_N)==K:
    ans += count()
else:
    if len(str_N)==1:
        ans += N
    else:
        ans += combinations_count(len(str_N)-1, K)*(9**K)
        ans += count()
print(ans)
