import strutils,sequtils,math,algorithm,future
template rep(a,b):seq = newSeqWith(b,a)

proc solve(N:string; K:int) =
  let N = N.mapIt(it.ord-'0'.ord)
  var d,p = 0.repeat(N.len).repeat(K+1)
  d[1][0] = 1
  p[1][0] = N[0]-1
  p[0][0] = 1
  for i in 1..<N.len:
    for j in 0..K:
      p[j][i].inc p[j][i-1]
      if N[i] == 0:
        d[j][i].inc d[j][i-1]
      else:
        p[j][i].inc d[j][i-1]
    for j in 0..<K:
      p[j+1][i].inc p[j][i-1]*9
      if N[i] != 0:
        p[j+1][i].inc d[j][i-1]*(N[i]-1)
        d[j+1][i].inc d[j][i-1]
  echo d,p
  echo d[^1][^1] + p[^1][^1]



when isMainModule:
  let get = iterator:string {.closure.} = 
    for s in stdin.readAll.split: yield s
  let N = get()
  let K = get().parseInt
  solve(N,K)

