fun main(args: Array<String>) {
    val N = readLine()!!
    val K = readLine()!!.toInt()

    val dp = Array(N.length + 1) { Array(K + 1) { LongArray(2) { 0L } } }
    dp[0][0][1] = 1
    dp[1][0][0] = 1

    for (i in N.indices) {
        dp[i + 1][0][0] += dp[i][0][0]

        for (k in 1..K) {
            dp[i + 1][k][0] += dp[i][k][0]

            if (N[i] == '0') {
                dp[i + 1][k][1] += dp[i][k][1]
            } else {
                dp[i + 1][k][1] += dp[i][k - 1][1]
                dp[i + 1][k][0] += dp[i][k - 1][1] * (N[i] - '0' - 1)
                dp[i + 1][k][0] += dp[i][k][1]
            }

            dp[i + 1][k][0] += dp[i][k - 1][0] * 9
        }
    }

    println(dp[N.length][K][0] + dp[N.length][K][1])
}
