import scala.util.control.Breaks._

object Main extends App {
  val n = io.StdIn.readInt()
  val k = io.StdIn.readInt()
  def countNot0(x: Int): Boolean = {
    var count = 0
    var tmp = x
    breakable{
      while(tmp != 0) {
        val d = tmp % 10
        tmp = tmp / 10
        if (d != 0) count += 1
        if (k < count) break
      }
    }
    if (count == k) true
    else false
  }
  println((1 to n).count(countNot0))
}