fun main(args: Array<String>) {

    fun fact(n: Long): Long {
        if (n == 1L) return 1L
        return n * fact(n - 1)
    }

    fun comb(n: Long, k: Long): Long {
        var r = 1L

        for (l in n downTo Math.max(n - k + 1, 1L)) {
            r *= l
        }

        for (l in k downTo 1) {
            r /= l
        }

        return r
    }

    val n = readLine()!!
    val k = readLine()!!.toInt()

    var ans = 0L

    val a = Math.pow(9.0, k - 1.0).toLong()

    for (i in 0 until n.length - 1) {

        val x = n[i].toString().toInt() * comb(n.length - i - 1L, k - 1L) * a
        ans += x

        if (i < n.lastIndex) {
            val y1 = n[i + 1].toString().toInt()
            val y2 = if (i + 1 < n.lastIndex) comb(n.length - i - 2L, k - 1L) * a else 1L
            ans -= 9 * y2 - y1 * y2
        }

    }

    println(ans)
}
