N=int(input())
K=int(input())
import math
ans=0
n=str(N)
a=len(n)
print(a)
def combi(p,q):
    return math.factorial(p)//(math.factorial(q)*math.factorial(p-q))
if a<K:
    ans=0
else:
    if a>K:
        ans+=combi(a-1,K)*(9**K)
        print(ans)
    if K==1:
        ans+=int(n[0])
    elif K==2:ans+=int(n[0])*(a-2)*9+(int(n[0])-1)*9+int(n[1])
    else:ans+=(int(n[0])-1)*81*(combi(a-1,2))+combi(a-2,2)*81+9*(a-2)*(int(n[1])-1)+int(n[2])+(a-3)*9

print(ans)