N=input()
n=int(N)
k=int(input())
ans=0
if k==1:
    for i in range(len(N)):
        if i>=2:
            ans+=1
        else:
            ans+=min(n,9)

elif k==2:
    for i in range(len(N)):
        if i<1:
            continue
        elif i==1:
            if n<100:
                ans=n-9-int(N[0])
            else:
                ans+=81
        elif i==len(N)-1:
            ans+=int(N[0])*9*(i-2)+int(N[0])*int(N[1])
        else:
            ans+=81*i
                



print(ans)