fun main(arg: Array<String>) {
    val N = next()
    val K = nextInt()
    val L = N.length
    val dp = Array(101) { Array(4) { IntArray(2) } }
    dp[0][0][0] = 1
    for (i in 0 until L)
        for (j in 0 until 4)
            for (k in 0 until 2) {
                val nd = N[i] - '0'
                for (d in 0 until 10) {
                    var ni = i + 1
                    var nj = j
                    var nk = k
                    if (d != 0) nj += 1
                    if (nj > K) continue
                    if (k == 0) {
                        if (d > nd) continue
                        if (d < nd) nk = 1
                    }
                    dp[ni][nj][nk] += dp[i][j][k]
                }
            }
    var ans = dp[L][K][0] + dp[L][K][1]
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
