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 flg = Array(N.size + 1) { Array(K + 1) { 0 } }
  flg[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]
    for (j in 1..K) dp[i][j] += dp[i - 1][j - 1] * 9
    // flg = false の場合
    for (j in 0..K) dp[i][j] += flg[i - 1][j]
    for (j in 1..K) dp[i][j] += flg[i - 1][j - 1] * (n - 1)
    for (j in 1..K) flg[i][j] += flg[i - 1][j - 1]
  }

  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() }
