N = input()
K = int(input())
L = len(N)

dp =[[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)]
# dp[i][j][flg] i+1桁目までで0以外の個数がj個
# flg = 1 -> N 以下が確定している

dp[0][1][1] = int(N[0])-1
dp[0][1][0] = 1
dp[0][0][1]=1
for i in range(1,L):
  for j in range(4):
    b = i-1 # hitotumae
    now = int(N[i])
    ## N上限に張り付いてる方
    if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
    dp[i][j][1] += dp[b][j][1]
    dp[i][j+1][1] += dp[b][j][1] * 9
  

print(dp[L-1][K][0] + dp[L-1][K][1]) N = input() N input() input K = int(input()) K int(input()) int input() input L = len(N) L len(N) len N [[ 0 for _ in range(2)] for _ in range(5)] 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 for _ in range(2)] for _ in range(5)] dp =[[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)] dp [[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)] dp[0][1][1] = int(N[0])-1 dp[0][1][1] [1] [0] dp 0 1 1 int(N[0])-1 int(N[0]) int N[0] N 0 1 dp[0][1][0] = 1 dp[0][1][0] [1] [0] dp 0 1 0 1 dp[0][0][1]=1 dp[0][0][1] [0] [0] dp 0 0 1 1 for i in range(1,L):
  for j in range(4):
    b = i-1 # hitotumae
    now = int(N[i])
    ## N上限に張り付いてる方
    if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
    dp[i][j][1] += dp[b][j][1]
    dp[i][j+1][1] += dp[b][j][1] * 9
   i range(1,L) range 1 L for j in range(4):
    b = i-1 # hitotumae
    now = int(N[i])
    ## N上限に張り付いてる方
    if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
    dp[i][j][1] += dp[b][j][1]
    dp[i][j+1][1] += dp[b][j][1] * 9
   j range(4) range 4 b = i-1 b i-1 i 1 now = int(N[i]) now int(N[i]) int N[i] N i if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
     now == 0 now 0 dp[i][j][0] += dp[b][j][0] dp[i][j][0] [j] [i] dp i j 0 dp[b][j][0] [j] [b] dp b j 0 dp[i][j][1] += dp[b][j][0] dp[i][j][1] [j] [i] dp i j 1 dp[b][j][0] [j] [b] dp b j 0 dp[i][j+1][1] += dp[b][j][0] * (now-1) dp[i][j+1][1] [j+1] [i] dp i j+1 j 1 1 dp[b][j][0] * (now-1) dp[b][j][0] [j] [b] dp b j 0 now-1 now 1 dp[i][j+1][0] += dp[b][j][0] dp[i][j+1][0] [j+1] [i] dp i j+1 j 1 0 dp[b][j][0] [j] [b] dp b j 0 dp[i][j][1] += dp[b][j][1] dp[i][j][1] [j] [i] dp i j 1 dp[b][j][1] [j] [b] dp b j 1 dp[i][j+1][1] += dp[b][j][1] * 9 dp[i][j+1][1] [j+1] [i] dp i j+1 j 1 1 dp[b][j][1] * 9 dp[b][j][1] [j] [b] dp b j 1 9 print(dp[L-1][K][0] + dp[L-1][K][1]) print dp[L-1][K][0] + dp[L-1][K][1] dp[L-1][K][0] [K] [L-1] dp L-1 L 1 K 0 dp[L-1][K][1] [K] [L-1] dp L-1 L 1 K 1 now = int(N[i]) int(N[i]) now b = i-1 i-1 b N = input() input() N L = len(N) len(N) L K = int(input()) int(input()) K dp =[[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)] [[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)] dp
N = input()
K = int(input())
L = len(N)

dp =[[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)]
# dp[i][j][flg] i+1桁目までで0以外の個数がj個
# flg = 1 -> N 以下が確定している

dp[0][1][1] = int(N[0])-1
dp[0][1][0] = 1
dp[0][0][1]=1
for i in range(1,L):
  for j in range(4):
    b = i-1 # hitotumae
    now = int(N[i])
    ## N上限に張り付いてる方
    if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
    dp[i][j][1] += dp[b][j][1]
    dp[i][j+1][1] += dp[b][j][1] * 9
  

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