def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

def naive(N,K):
    count=0
    for i in range(1,N+1):
        if str(i).count("0")==len(str(i))-K:
            count+=1
    return count

import itertools 

N=one_int()
K=one_int()

sums = 0
N_len = len(str(N))
if N_len!=K:
    for i in range(K,0,-1):
        temp =list(itertools.combinations([j for j in range(N_len-i)],K-i+1))
    #     sums += 9**(i)
        add = 1
        if K>=i>1:
            add=naive(int(str(N)[:i-1]),i-1)
        sums += (9**(K-i+1)) * max((len(temp)),0) * add  
sums += naive(int(str(N)[:K]), K)

print(sums)
