s = input()
K = int(input())
n =len(s)

dp = [[[0] * 2 for _ in range(4)] for _ in range(101)]

dp[0][0][0]=1
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])

            for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp]

ans=dp[n][K][0] + dp[n][K][1]
print(ans)
# [print(i) for i in dp] s = input() s input() input K = int(input()) K int(input()) int input() input n =len(s) n len(s) len s [[0] * 2 for _ in range(4)] for _ in range(101) for _ in range(101) _ range(101) range 101 for _ in range(101) [[0] * 2 for _ in range(4)] dp = [[[0] * 2 for _ in range(4)] for _ in range(101)] dp [[[0] * 2 for _ in range(4)] for _ in range(101)] dp[0][0][0]=1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])

            for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp] i range(n) range n for j in range(4):
        for k in range(2):
            nd = int(s[i])

            for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp] j range(4) range 4 for k in range(2):
            nd = int(s[i])

            for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp] k range(2) range 2 nd = int(s[i]) nd int(s[i]) int s[i] s i for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp] d range(10) range 10 ni = i+1 ni i+1 i 1 nj = j nj j nk = k nk k if d != 0 :nj+=1
                 d != 0 d 0 if nj > K:continue
                 nj > K nj K if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                 k==0 k 0 if d > nd:continue
                     d > nd d nd if d < nd:nk =1
                 d < nd d nd dp[ni][nj][nk] += dp[i][j][k] dp[ni][nj][nk] [nj] [ni] dp ni nj nk dp[i][j][k] [j] [i] dp i j k ans=dp[n][K][0] + dp[n][K][1] ans 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 print(ans) print ans s = input() input() s nk = k k nk ans=dp[n][K][0] + dp[n][K][1] dp[n][K][0] + dp[n][K][1] ans n =len(s) len(s) n K = int(input()) int(input()) K dp = [[[0] * 2 for _ in range(4)] for _ in range(101)] [[[0] * 2 for _ in range(4)] for _ in range(101)] dp nj = j j nj ni = i+1 i+1 ni nd = int(s[i]) int(s[i]) nd
s = input()
K = int(input())
n =len(s)

dp = [[[0] * 2 for _ in range(4)] for _ in range(101)]

dp[0][0][0]=1
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])

            for d in range(10):
                ni = i+1; nj = j; nk = k

                if d != 0 :nj+=1
                if nj > K:continue
                if k==0:
                    if d > nd:continue
                    if d < nd:nk =1
                dp[ni][nj][nk] += dp[i][j][k]
                # print(d,k)
                # print(i,j,k,dp[i][j][k])
                # print(ni,nj,nk,dp[ni][nj][nk])
                # [print(i) for i in dp]

ans=dp[n][K][0] + dp[n][K][1]
print(ans)
# [print(i) for i in dp]