import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val N = readDouble
    val K = readInt

    val list: List[BigDecimal] = {
      for {
        n <- BigDecimal(1.0) to BigDecimal(N) by 1.0
        if getNumberOfNonZeros(n) == K
      } yield n
    }.toList

    println(list.length)
  }



  def getNumberOfNonZeros(num: BigDecimal): Int =
    num.toString.toList.count(c => c != '0')

  def readToInts(): Array[Int] = readLine.split(" ").map(_.toInt)
  def readToListInts(): List[Int] = readLine.split(" ").map(_.toInt).toList
  def readToVectorInts(): Vector[Int] = readLine.split(" ").map(_.toInt).toVector

}