N = list(map(int,input()))
K = int(input())

def f(n,k):
  if k == 1:
    if len(n) == 1:
      return n[0]
    else:
      r = n[-1]
      m = n[:-1]
      return f(m,1) + 9
  else:
    if len(n) == 1:
      return 0
    else:
      r = n[-1]
      m = n[:-1]
      m2 = m.copy()
      if all(elem == 0 for elem in m):
        pass
      else:
        m2[-1] = m2[-1] - 1
        for i in range(len(m)):
          if m2[-i] < 0:
            m2[-i] = 9
            m2[-i-1] = m2[-i-1]
      return f(m,k) + f(m,k-1) * r + f(m2,k-1) * (9-r)
    
print(f(N,K))