from math import factorial

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

n=int(input())
k=int(input())
ans=0
nstr=str(n)
nl=len(nstr)
for i in range(k,nl):
    ans+=combinations_count(i-1,k-1)
ans*=9**k
zerocnt=0
for i in range(nl):
    if zerocnt<=nl-k:
        if i==0:
            ans+=(int(nstr[0])-1)*combinations_count(nl-1,k-1)*(9**(k-1))
        else:
            if nstr[i]=='0':
                zerocnt+=1
            else:
                ans+=(int(nstr[i])-1)*combinations_count(nl-i-1,k-i+zerocnt-1)*9**(k-i+zerocnt-1)
    else:
        break
print(ans)