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

    // 1: Nと一致, 0: Nより真に小さい
    val dp = Array(101) { Array(4) { Array(2) { 0 } } }
    dp[0][0][1] = 1

    var ans = 0
    for (len in n.indices) {
        for (countNotZero in 0..k) {
            for (matchN in 0..1) {
                if (dp[len][countNotZero][matchN] == 0) continue

                for (nextDigit in '0'..'9') {
                    var nextMatchN = matchN
                    if (matchN == 1) {
                        if (nextDigit > n[len]) {
                            continue
                        } else if (nextDigit < n[len]) {
                            nextMatchN = 0
                        }
                    }

                    var nextCountNotZero = countNotZero
                    if (nextDigit != '0') {
                        nextCountNotZero++
                    }

                    if (nextCountNotZero <= k) {
                        dp[len + 1][nextCountNotZero][nextMatchN] += dp[len][countNotZero][matchN]
                    }
                }
            }
        }
    }
    println(dp[n.length][k][0] + dp[n.length][k][1])
}
