fun main(args: Array<String>) {
    abc154e()
}

fun abc154e() {
    val s = readLine()!!
    val K = readLine()!!.toInt()
    val n = s.length

    val dp = Array(105) { Array(4) { LongArray(2) } }
    dp[0][0][0] = 1

    for (i in 0 until n) {
        for (j in 0..K) {
            for (k in 0..1) {
                val nd = s[i] - '0'
                for (d in 0..9) {
                    val ni = i + 1
                    var nj = j
                    var nk = k
                    if (d != 0) nj++
                    if (nj > K) continue
                    if (k == 0) {
                        if (d > nd) continue
                        if (d < nd) nk = 1
                    }
                    dp[ni][nj][nk] += dp[i][j][k]
                }
            }
        }
    }

    val answer = dp[n][K].sum()

    return println(answer)
}
