n,K=input(),int(input())
m=len(n)

DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)]
DP[0][0][0]=1

for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j]

print(DP[m][0][K]+DP[m][1][K]) n,K=input(),int(input()) n input() input K int(input()) int input() input m=len(n) m len(n) len n [[0]*(K+2) for _ in range(2)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [[0]*(K+2) for _ in range(2)] DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] DP [[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] DP[0][0][0]=1 DP[0][0][0] [0] [0] DP 0 0 0 1 for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j] i range(1,m+1) range 1 m+1 m 1 for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j] flag range(2) range 2 num=9 if flag else int(n[i-1]) num 9 if flag else int(n[i-1]) flag 9 int(n[i-1]) int n[i-1] n i-1 i 1 for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j] j range(K+1) range K+1 K 1 for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j] k range(num+1) range num+1 num 1 if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j] k!=0 k 0 print(DP[m][0][K]+DP[m][1][K]) print DP[m][0][K]+DP[m][1][K] DP[m][0][K] [0] [m] DP m 0 K DP[m][1][K] [1] [m] DP m 1 K num=9 if flag else int(n[i-1]) 9 if flag else int(n[i-1]) num K=input(),int(input()) int(input()) K n,K=input(),int(input()) input() n DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] [[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] DP m=len(n) len(n) m
n,K=input(),int(input())
m=len(n)

DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)]
DP[0][0][0]=1

for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j]

print(DP[m][0][K]+DP[m][1][K])