main=do
 n<-getLine
 k<-readLn
 print$f n k
f n k
 |k==0=1
 |null n=0
 |head n=='0'=0
 |otherwise=(f(tail n)(k-1))+(f s(k-1))*(l-1)+f s k
  where s=map(const '9')$tail n
        l=subtract 48$fromEnum$head n