n = int(input())
k = int(input())
n_len = len(str(n))

x = [1]*(n_len)
for i in range(n_len-1):
    x[i+1] = x[i]*(i+1)

def calc(i,j):
    return x[i]/x[j]/x[i-j]*9**(j)
    
count = 0
non_zero = 0
for ind,i in enumerate(str(n)):
    if i != '0':
        non_zero += 1
        if n_len-ind-1 > k-non_zero:
            count += calc(n_len-ind-1,k-non_zero+1)
        if non_zero < k:
            count += calc(n_len-ind-1,k-non_zero)*(int(i)-1)
        elif non_zero == k:
            count += int(i)
            break
    
print(int(count))