# Problem E - Almost Everywhere Zero

# input
N = list(input())
N = list(map(int, N))
K = int(input())

# initialization
dp = [[[0]*4 for i in range(2)] for j in range(len(N)+1)] # dp[keta][smaller][nums]
dp[0][0][0] = 1

# dp
for keta in range(len(N)): # keta loop
    for smaller in range(2): # smaller loop
        limit = 0
        if smaller==0:
            limit = N[keta]
        else:
            limit = 9
        for n in range(limit + 1):
            # not 0 update
            if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output
ans = dp[len(N)][0][K] + dp[len(N)][1][K]
print(ans) N = list(input()) N list(input()) list input() input N = list(map(int, N)) N list(map(int, N)) list map(int, N) map int N K = int(input()) K int(input()) int input() input [[0]*4 for i in range(2)] for j in range(len(N)+1) for j in range(len(N)+1) j range(len(N)+1) range len(N)+1 len(N) len N 1 for j in range(len(N)+1) [[0]*4 for i in range(2)] dp = [[[0]*4 for i in range(2)] for j in range(len(N)+1)] dp [[[0]*4 for i in range(2)] for j in range(len(N)+1)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for keta in range(len(N)): # keta loop
    for smaller in range(2): # smaller loop
        limit = 0
        if smaller==0:
            limit = N[keta]
        else:
            limit = 9
        for n in range(limit + 1):
            # not 0 update
            if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output keta range(len(N)) range len(N) len N for smaller in range(2): # smaller loop
        limit = 0
        if smaller==0:
            limit = N[keta]
        else:
            limit = 9
        for n in range(limit + 1):
            # not 0 update
            if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output smaller range(2) range 2 limit = 0 limit 0 if smaller==0:
            limit = N[keta]
        else:
            limit = 9
         smaller==0 smaller 0 limit = N[keta] limit N[keta] N keta limit = 9 limit 9 for n in range(limit + 1):
            # not 0 update
            if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output n range(limit + 1) range limit + 1 limit 1 if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output n==0 n 0 for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
             x range(4) range 4 dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x] dp[keta+1][smaller or n<limit][x] [smaller or n<limit] [keta+1] dp keta+1 keta 1 smaller or n<limit smaller n<limit n limit x dp[keta][smaller][x] [smaller] [keta] dp keta smaller x for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output x range(2, -1, -1) range 2 -1 -1 dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x] dp[keta+1][smaller or n<limit][x+1] [smaller or n<limit] [keta+1] dp keta+1 keta 1 smaller or n<limit smaller n<limit n limit x+1 x 1 dp[keta][smaller][x] [smaller] [keta] dp keta smaller x ans = dp[len(N)][0][K] + dp[len(N)][1][K] ans dp[len(N)][0][K] + dp[len(N)][1][K] dp[len(N)][0][K] [0] [len(N)] dp len(N) len N 0 K dp[len(N)][1][K] [1] [len(N)] dp len(N) len N 1 K print(ans) print ans N = list(map(int, N)) list(map(int, N)) N K = int(input()) int(input()) K dp = [[[0]*4 for i in range(2)] for j in range(len(N)+1)] [[[0]*4 for i in range(2)] for j in range(len(N)+1)] dp limit = 0 0 limit limit = N[keta] N[keta] limit ans = dp[len(N)][0][K] + dp[len(N)][1][K] dp[len(N)][0][K] + dp[len(N)][1][K] ans limit = 9 9 limit N = list(input()) list(input()) N
# Problem E - Almost Everywhere Zero

# input
N = list(input())
N = list(map(int, N))
K = int(input())

# initialization
dp = [[[0]*4 for i in range(2)] for j in range(len(N)+1)] # dp[keta][smaller][nums]
dp[0][0][0] = 1

# dp
for keta in range(len(N)): # keta loop
    for smaller in range(2): # smaller loop
        limit = 0
        if smaller==0:
            limit = N[keta]
        else:
            limit = 9
        for n in range(limit + 1):
            # not 0 update
            if n==0:
                for x in range(4):
                    dp[keta+1][smaller or n<limit][x] += dp[keta][smaller][x]
            else:
                for x in range(2, -1, -1):
                    dp[keta+1][smaller or n<limit][x+1] += dp[keta][smaller][x]

# output
ans = dp[len(N)][0][K] + dp[len(N)][1][K]
print(ans)
