import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.next()
	val k = scn.nextInt()
	val dpc = Array(n.length){LongArray(k+1)}
	val dpuc = Array(n.length){LongArray(k+1)}
	dpc[0][0] = 1
	dpc[0][1] = Integer.parseInt(n.substring(0,1))-1L
	dpuc[0][1] = 1
	for (i in 1 until n.length){
		dpc[i][0] = 1
		for (j in 1..Math.min(i+1, k)){
			dpc[i][j] = dpc[i-1][j] + 9*dpc[i-1][j-1]
			if (n[i].toInt()>0){
				dpc[i][j] += (Integer.parseInt(n.substring(i, i+1))-1)*dpuc[i-1][j-1] + dpuc[i-1][j]
				dpuc[i][j] = dpuc[i-1][j-1]
			}else {
				dpuc[i][j] = dpuc[i-1][j]
			}
		}
	}
	println(dpc[n.length-1][k]+dpuc[n.length-1][k])
}