fun main(A: Array<String>) {
    val s = java.util.Scanner(System.`in`)
    val n = s.next()
    val k = s.nextInt()

    val a = Array(n.length) { Array(2) { LongArray(k + 1) { 0L } } }

    a[0][0][1] = (n[0] - '1').toLong()
    a[0][1][1] = 1

    for (i in 1 until n.length) {
        val t = a[i - 1]
        val u = a[i]
        val c = n[i]

        if (c == '0') {
            for (j in 0..k)
                u[1][j] += t[1][j]
        } else {
            for (j in 0..k)
                u[0][j] += t[1][j]
            for (j in 1..k) {
                u[1][j] += t[1][j - 1]
                u[0][j] += t[1][j - 1] * (c - '1')
            }
        }

        for (j in 0..k) {
            u[0][j] += t[0][j]
        }
        for (j in 1..k) {
            u[0][j] += t[0][j - 1] * 9
        }
        u[0][1] += 9L
    }

    println(a.last().map { it[k] }.sum())
}
