n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1
10
for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p])) n = str(input()) n str(input()) str input() input p = int(input()) p int(input()) int input() input keta = len(n) keta len(n) len n [[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1) for _ in range(keta+1) _ range(keta+1) range keta+1 keta 1 for _ in range(keta+1) [[0 for _ in range(2)] for _ in range(keta+1)] Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)] Dp [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)] Dp[0][0][1] = 1 Dp[0][0][1] [0] [0] Dp 0 0 1 1 10 for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0] i range(keta) range keta for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0] j range(i+1) range i+1 i 1 for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0] k range(10) range 10 if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0] k == 0 k 0 if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
             k < int(n[i]) k int(n[i]) int n[i] n i Dp[i+1][j][0] += Dp[i][j][0] Dp[i+1][j][0] [j] [i+1] Dp i+1 i 1 j 0 Dp[i][j][0] [j] [i] Dp i j 0 Dp[i+1][j][0] += Dp[i][j][1] Dp[i+1][j][0] [j] [i+1] Dp i+1 i 1 j 0 Dp[i][j][1] [j] [i] Dp i j 1 elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                 k == int(n[i]) k int(n[i]) int n[i] n i Dp[i+1][j][1] += Dp[i][j][1] Dp[i+1][j][1] [j] [i+1] Dp i+1 i 1 j 1 Dp[i][j][1] [j] [i] Dp i j 1 Dp[i+1][j][0] += Dp[i][j][0] Dp[i+1][j][0] [j] [i+1] Dp i+1 i 1 j 0 Dp[i][j][0] [j] [i] Dp i j 0 Dp[i+1][j][0] += Dp[i][j][0] Dp[i+1][j][0] [j] [i+1] Dp i+1 i 1 j 0 Dp[i][j][0] [j] [i] Dp i j 0 if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0] k < int(n[i]) k int(n[i]) int n[i] n i Dp[i+1][j+1][0] += Dp[i][j][0] Dp[i+1][j+1][0] [j+1] [i+1] Dp i+1 i 1 j+1 j 1 0 Dp[i][j][0] [j] [i] Dp i j 0 Dp[i+1][j+1][0] += Dp[i][j][1] Dp[i+1][j+1][0] [j+1] [i+1] Dp i+1 i 1 j+1 j 1 0 Dp[i][j][1] [j] [i] Dp i j 1 elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                 k == int(n[i]) k int(n[i]) int n[i] n i Dp[i+1][j+1][1] += Dp[i][j][1] Dp[i+1][j+1][1] [j+1] [i+1] Dp i+1 i 1 j+1 j 1 1 Dp[i][j][1] [j] [i] Dp i j 1 Dp[i+1][j+1][0] += Dp[i][j][0] Dp[i+1][j+1][0] [j+1] [i+1] Dp i+1 i 1 j+1 j 1 0 Dp[i][j][0] [j] [i] Dp i j 0 Dp[i+1][j+1][0] += Dp[i][j][0] Dp[i+1][j+1][0] [j+1] [i+1] Dp i+1 i 1 j+1 j 1 0 Dp[i][j][0] [j] [i] Dp i j 0 if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p])) p > keta p keta print(0) print 0 print(sum(Dp[-1][p])) print sum(Dp[-1][p]) sum Dp[-1][p] [-1] Dp -1 p Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)] [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)] Dp keta = len(n) len(n) keta p = int(input()) int(input()) p n = str(input()) str(input()) n
n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1
10
for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p]))