N=int(input())
K=int(input())

string = str(N)
digits = len(string)

#dp[i][j][k]=と同じ桁数の整数で上からi桁目までで0でない数字がj個あるものの個数
#k=0: i桁目まで見てN未満が確定, k=1: 未確定
dp = [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)]
#初期状態
dp[0][0][1] = 1

for i in range(digits):
    d = int(string[i])
    ni = i+1
    for j in range(K+1):
        for k in range(2):
            for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k]

print(dp[digits][K][0] + dp[digits][K][1]) N=int(input()) N int(input()) int input() input K=int(input()) K int(input()) int input() input string = str(N) string str(N) str N digits = len(string) digits len(string) len string [[0]*2 for _ in range(K+1)] for __ in range(digits+1) for __ in range(digits+1) __ range(digits+1) range digits+1 digits 1 for __ in range(digits+1) [[0]*2 for _ in range(K+1)] dp = [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)] dp [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)] dp[0][0][1] = 1 dp[0][0][1] [0] [0] dp 0 0 1 1 for i in range(digits):
    d = int(string[i])
    ni = i+1
    for j in range(K+1):
        for k in range(2):
            for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k] i range(digits) range digits d = int(string[i]) d int(string[i]) int string[i] string i ni = i+1 ni i+1 i 1 for j in range(K+1):
        for k in range(2):
            for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k] j range(K+1) range K+1 K 1 for k in range(2):
            for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k] k range(2) range 2 for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k] nd range(10) range 10 nk = 1 if k == 1 and nd == d else 0 nk 1 if k == 1 and nd == d else 0 k == 1 and nd == d k == 1 k 1 nd == d nd d 1 0 if k == 1 and nd > d: break

                 k == 1 and nd > d k == 1 k 1 nd > d nd d nj = j + (1 if nd != 0 else 0) nj j + (1 if nd != 0 else 0) j 1 if nd != 0 else 0 nd != 0 nd 0 1 0 if nj > K: continue

                 nj > K nj K 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 print(dp[digits][K][0] + dp[digits][K][1]) print dp[digits][K][0] + dp[digits][K][1] dp[digits][K][0] [K] [digits] dp digits K 0 dp[digits][K][1] [K] [digits] dp digits K 1 K=int(input()) int(input()) K nk = 1 if k == 1 and nd == d else 0 1 if k == 1 and nd == d else 0 nk ni = i+1 i+1 ni string = str(N) str(N) string dp = [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)] [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)] dp digits = len(string) len(string) digits d = int(string[i]) int(string[i]) d N=int(input()) int(input()) N nj = j + (1 if nd != 0 else 0) j + (1 if nd != 0 else 0) nj
N=int(input())
K=int(input())

string = str(N)
digits = len(string)

#dp[i][j][k]=と同じ桁数の整数で上からi桁目までで0でない数字がj個あるものの個数
#k=0: i桁目まで見てN未満が確定, k=1: 未確定
dp = [[[0]*2 for _ in range(K+1)] for __ in range(digits+1)]
#初期状態
dp[0][0][1] = 1

for i in range(digits):
    d = int(string[i])
    ni = i+1
    for j in range(K+1):
        for k in range(2):
            for nd in range(10):
                nk = 1 if k == 1 and nd == d else 0
                if k == 1 and nd > d: break

                nj = j + (1 if nd != 0 else 0)
                if nj > K: continue

                dp[ni][nj][nk] += dp[i][j][k]

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