N = input()
K = int(input())

if len(N) < K:
  print(0)
  exit()

ans = [1, int(N[-1]), 0, 0];

def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p

for k in range(1, len(N)):
  if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = a
print(ans[K]) N = input() N input() input K = int(input()) K int(input()) int input() input if len(N) < K:
  print(0)
  exit() len(N) < K len(N) len N K print(0) print 0 exit() exit ans = [1, int(N[-1]), 0, 0] ans [1, int(N[-1]), 0, 0] 1 int(N[-1]) int N[-1] N -1 0 0 def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p combination if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p N < K N K return 0 0 p = 1 p 1 for k in range(K):
      p *= N
      N -= 1
     k range(K) range K p *= N p N N -= 1 N 1 for k in range(1, K+1):
      p //= k
     k range(1, K+1) range 1 K+1 K 1 p //= k p k return p p N N K K for k in range(1, len(N)):
  if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = a k range(1, len(N)) range 1 len(N) len N if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = a int(N[-k-1]) > 0 int(N[-k-1]) int N[-k-1] N -k-1 -k k 1 0 a = [1, 0, 0, 0] a [1, 0, 0, 0] 1 0 0 0 for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
     j range(1, K+1) range 1 K+1 K 1 a[j] += (9**(j))*combination(k, j) a[j] a j (9**(j))*combination(k, j) 9**(j) 9 j combination(k, j) combination k j a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1] a[j] a j (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1] (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) (int(N[-k-1])-1)*combination(k, j-1) int(N[-k-1])-1 int(N[-k-1]) int N[-k-1] N -k-1 -k k 1 1 combination(k, j-1) combination k j-1 j 1 9**(j-1) 9 j-1 j 1 ans[j-1] ans j-1 j 1 ans = a ans a print(ans[K]) print ans[K] ans K ans = a a ans K = int(input()) int(input()) K def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p combination a = [1, 0, 0, 0] [1, 0, 0, 0] a ans = [1, int(N[-1]), 0, 0] [1, int(N[-1]), 0, 0] ans N = input() input() N
N = input()
K = int(input())

if len(N) < K:
  print(0)
  exit()

ans = [1, int(N[-1]), 0, 0];

def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p

for k in range(1, len(N)):
  if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = a
print(ans[K])