fun main(args: Array<String>) {
  val N = readString().map { it.toString().toInt() }
  val K = readInt()

  val dp = Array(N.size + 1) { Array(K + 1) { 0 } }
  val fg = Array(N.size + 1) { Array(K + 1) { 0 } }
  fg[0][0] = 1
  for (i in 1..N.size) {
    val n = N[i - 1]
    // flg = true の場合
    for (j in 0..K) dp[i][j] += dp[i - 1][j] // 確定 → 0
    for (j in 1..K) dp[i][j] += dp[i - 1][j - 1] * 9 // 確定 → 1~9
    // flg = false の場合
    if (n > 0) {
      for (j in 0..K) dp[i][j] += fg[i - 1][j] // 未確定 → 0
      for (j in 1..K) dp[i][j] += fg[i - 1][j - 1] * (n - 1) // 未確定 → 1~(n-1)
      for (j in 1..K) fg[i][j] += fg[i - 1][j - 1] // 未確定 → n
    } else {
      for (j in 1..K) fg[i][j] += fg[i - 1][j] // 未確定 → 未確定
    }
  }

  println(dp[N.size][K])
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }
