object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val n = sc.next
	val k = sc.nextInt
	
	val m0 = Array.fill(k+1)(Array.fill(2)(0))
	m0(0)(0) = 1
	
	pw.println(n.map(_.asDigit).foldLeft(m0) { case (pm, ni) =>
		val m = pm.clone.collect {
			case Array(mj0, mj1) if (ni != 0) => Array(0, mj0 + mj1)
		}

		for (j <- (1 to k)) {
			m(j)(0) += pm(j-1)(0)
			m(j)(1) += (pm(j-1)(0) * (ni-1)) + (pm(j-1)(1) * 9)
		}
		
		m
	}(k).sum)
	
	pw.flush()
}