N,K=int(input()),int(input())
def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k)
print(f(N,K)) N,K=int(input()),int(input()) N int(input()) int input() input K int(input()) int input() input def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k) f if k<1: return 1
   k<1 k 1 if n<10:
    if k<2: return n
    return 0
   n<10 n 10 if k<2: return n
     k<2 k 2 return 0 0 d,m=n//10,n%10 d n//10 n 10 m n%10 n 10 return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k) f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k) f(d,k-1)*m+f(d-1,k-1)*(9-m) f(d,k-1)*m f(d,k-1) f d k-1 k 1 m f(d-1,k-1)*(9-m) f(d-1,k-1) f d-1 d 1 k-1 k 1 9-m 9 m f(d,k) f d k n n k k print(f(N,K)) print f(N,K) f N K N,K=int(input()),int(input()) int(input()) N K=int(input()),int(input()) int(input()) K def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k) def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k) f
N,K=int(input()),int(input())
def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k)
print(f(N,K))