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

dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)]
dp[0][0][0] = 1

for i in range(len(N)):
  n = int(N[i])
  for j in range(K+1):
    for k in range(2): # smaller(未満なら1)
      for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k]

print(dp[-1][K][0] + dp[-1][K][1])


         N = str(input()) N str(input()) str input() input K = int(input()) K int(input()) int input() input [[0]*2 for _ in range(K+1)] for _ in range(len(N)+1) for _ in range(len(N)+1) _ range(len(N)+1) range len(N)+1 len(N) len N 1 for _ in range(len(N)+1) [[0]*2 for _ in range(K+1)] dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)] dp [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i in range(len(N)):
  n = int(N[i])
  for j in range(K+1):
    for k in range(2): # smaller(未満なら1)
      for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k] i range(len(N)) range len(N) len N n = int(N[i]) n int(N[i]) int N[i] N i for j in range(K+1):
    for k in range(2): # smaller(未満なら1)
      for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k] j range(K+1) range K+1 K 1 for k in range(2): # smaller(未満なら1)
      for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k] k range(2) range 2 for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k] l range(10) range 10 nj, nk = j, 0 nj j nk 0 if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
         k == 0 and l == n k == 0 k 0 l == n l n nk = 0 nk 0 elif k == 0 and l < n:
          nk = 1
         k == 0 and l < n k == 0 k 0 l < n l n nk = 1 nk 1 elif k == 0 and l > n:
          continue
        
         k == 0 and l > n k == 0 k 0 l > n l n continue if k == 1:
          nk = 1
        
         k == 1 k 1 nk = 1 nk 1 if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
         l != 0 l 0 if j < K:
            nj += 1
          else:
            continue
        
         j < K j K nj += 1 nj 1 continue dp[i+1][nj][nk] += dp[i][j][k] dp[i+1][nj][nk] [nj] [i+1] dp i+1 i 1 nj nk dp[i][j][k] [j] [i] dp i j k print(dp[-1][K][0] + dp[-1][K][1]) print dp[-1][K][0] + dp[-1][K][1] dp[-1][K][0] [K] [-1] dp -1 K 0 dp[-1][K][1] [K] [-1] dp -1 K 1 nk = 1 1 nk n = int(N[i]) int(N[i]) n dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)] [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)] dp nj, nk = j, 0 j nj nk = j, 0 0 nk nk = 1 1 nk K = int(input()) int(input()) K nj += 1 1 nj N = str(input()) str(input()) N nk = 0 0 nk
N = str(input())
K = int(input())

dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)]
dp[0][0][0] = 1

for i in range(len(N)):
  n = int(N[i])
  for j in range(K+1):
    for k in range(2): # smaller(未満なら1)
      for l in range(10): 
        nj, nk = j, 0
        if k == 0 and l == n:
          nk = 0
        elif k == 0 and l < n:
          nk = 1
        elif k == 0 and l > n:
          continue
        
        if k == 1:
          nk = 1
        
        if l != 0:
          if j < K:
            nj += 1
          else:
            continue
        
        dp[i+1][nj][nk] += dp[i][j][k]

print(dp[-1][K][0] + dp[-1][K][1])


        
