def comb(x,y):
    if y==1:
        return x
    elif y==2:
        return max(x*(x-1)//2, 0)
    elif y==3:
        return max(x*(x-1)*(x-2)//6, 0)
n = int(input())
k = int(input())
digit = len(str(n))
ans1 = comb(digit-1, k) * (9**k)
lst = [int(i) for i in list(str(n))]
if digit - list(str(n)).count('0') < k:
    print(0)
    exit()
if k==1:
    ans2 = lst[0]
    
elif k==2:
    ans2 = 0
    ans2 += (lst[0]-1) * (digit-1) * 9
    ans2 += lst[1] + (digit-2)*9
    
elif k==3:
    ans2 = 0
    ans2 += (lst[0]-1) * comb(digit-1, 2) * (9**2)
    ans2 += lst[1]*(digit-2)*9 + comb(digit-2, 2)*(9**2)
print(ans1+ans2)