
S = list(input())
K = int(input())
N = len(S)

# print(S)

# dp[i][j][k]
dp = [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)]

dp[0][0][0] = 1

# 上の桁から調べていく
for i in range(1, N + 1):
    for j in range(K + 1):
        for k in range(2):
            for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp)

print(dp[N][K][0] + dp[N][K][1]) S = list(input()) S list(input()) list input() input K = int(input()) K int(input()) int input() input N = len(S) N len(S) len S [[0] * 2 for _ in range(K+2)] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [[0] * 2 for _ in range(K+2)] dp = [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)] dp [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i in range(1, N + 1):
    for j in range(K + 1):
        for k in range(2):
            for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) i range(1, N + 1) range 1 N + 1 N 1 for j in range(K + 1):
        for k in range(2):
            for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) j range(K + 1) range K + 1 K 1 for k in range(2):
            for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) k range(2) range 2 for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) num range(10) range 10 if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                 num == 0 num 0 inc = 0 inc 0 inc = 1 inc 1 if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) k == 1 k 1 dp[i][j+inc][k] += dp[i - 1][j][k] dp[i][j+inc][k] [j+inc] [i] dp i j+inc j inc k dp[i - 1][j][k] [j] [i - 1] dp i - 1 i 1 j k if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) num < int(S[i-1]) num int(S[i-1]) int S[i-1] S i-1 i 1 dp[i][j + inc][1] += dp[i - 1][j][k] dp[i][j + inc][1] [j + inc] [i] dp i j + inc j inc 1 dp[i - 1][j][k] [j] [i - 1] dp i - 1 i 1 j k elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp) num == int(S[i-1]) num int(S[i-1]) int S[i-1] S i-1 i 1 dp[i][j + inc][0] += dp[i - 1][j][k] dp[i][j + inc][0] [j + inc] [i] dp i j + inc j inc 0 dp[i - 1][j][k] [j] [i - 1] dp i - 1 i 1 j k print(dp[N][K][0] + dp[N][K][1]) print dp[N][K][0] + dp[N][K][1] dp[N][K][0] [K] [N] dp N K 0 dp[N][K][1] [K] [N] dp N K 1 N = len(S) len(S) N inc = 1 1 inc inc = 0 0 inc dp = [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)] [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)] dp S = list(input()) list(input()) S K = int(input()) int(input()) K

S = list(input())
K = int(input())
N = len(S)

# print(S)

# dp[i][j][k]
dp = [[[0] * 2 for _ in range(K+2)] for _ in range(N+1)]

dp[0][0][0] = 1

# 上の桁から調べていく
for i in range(1, N + 1):
    for j in range(K + 1):
        for k in range(2):
            for num in range(10):
                if num == 0:
                    inc = 0
                else:
                    inc = 1
                # N未満が確定していれば0-9の全ての遷移が可能なので加える
                if k == 1:
                    dp[i][j+inc][k] += dp[i - 1][j][k]
                else:
                    if num < int(S[i-1]):
                        # k = 1が確定
                        dp[i][j + inc][1] += dp[i - 1][j][k]
                    elif num == int(S[i-1]):
                        # k = 0のまま
                        dp[i][j + inc][0] += dp[i - 1][j][k]

# print(dp)

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