#!/usr/bin python3
# -*- coding: utf-8 -*-
# 桁DP
# 1以上n以下の整数であって、 10進法で表したときに、0でない数字がちょうど
# k個あるようなものの個数

n = input()
k = int(input())
l = len(n)
#dp[i][j][status]   status=0 は小さいのが未確定=i文字まで同じ
#                   status=1 は小さいことが確定
# i桁目まで決めて、0でない桁がj個
# 初期値は1 からスタート s=0,i=0,j=0
dp = [[[0]*2 for j in range(k+1)] for i in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    ni = int(n[i])
    for j in range(k+1):
        for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st]

print(sum(dp[l][k])) n = input() n input() input k = int(input()) k int(input()) int input() input l = len(n) l len(n) len n [[0]*2 for j in range(k+1)] for i in range(l+1) for i in range(l+1) i range(l+1) range l+1 l 1 for i in range(l+1) [[0]*2 for j in range(k+1)] dp = [[[0]*2 for j in range(k+1)] for i in range(l+1)] dp [[[0]*2 for j in range(k+1)] for i in range(l+1)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i in range(l):
    ni = int(n[i])
    for j in range(k+1):
        for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st] i range(l) range l ni = int(n[i]) ni int(n[i]) int n[i] n i for j in range(k+1):
        for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st] j range(k+1) range k+1 k 1 for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st] st range(2) range 2 for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st] x range(10) range 10 i_ = i+1 i_ i+1 i 1 j_ = j j_ j st_ = st st_ st if x != 0:
                    j_ += 1
                 x != 0 x 0 j_ += 1 j_ 1 if j_ > k:
                    continue
                 j_ > k j_ k continue if st_ == 0 and x > ni:
                    continue
                 st_ == 0 and x > ni st_ == 0 st_ 0 x > ni x ni continue if st_ == 0 and x < ni:
                    st_ = 1
                 st_ == 0 and x < ni st_ == 0 st_ 0 x < ni x ni st_ = 1 st_ 1 dp[i_][j_][st_] += dp[i][j][st] dp[i_][j_][st_] [j_] [i_] dp i_ j_ st_ dp[i][j][st] [j] [i] dp i j st print(sum(dp[l][k])) print sum(dp[l][k]) sum dp[l][k] [l] dp l k dp = [[[0]*2 for j in range(k+1)] for i in range(l+1)] [[[0]*2 for j in range(k+1)] for i in range(l+1)] dp j_ = j j j_ st_ = st st st_ k = int(input()) int(input()) k j_ += 1 1 j_ st_ = 1 1 st_ l = len(n) len(n) l i_ = i+1 i+1 i_ n = input() input() n ni = int(n[i]) int(n[i]) ni
#!/usr/bin python3
# -*- coding: utf-8 -*-
# 桁DP
# 1以上n以下の整数であって、 10進法で表したときに、0でない数字がちょうど
# k個あるようなものの個数

n = input()
k = int(input())
l = len(n)
#dp[i][j][status]   status=0 は小さいのが未確定=i文字まで同じ
#                   status=1 は小さいことが確定
# i桁目まで決めて、0でない桁がj個
# 初期値は1 からスタート s=0,i=0,j=0
dp = [[[0]*2 for j in range(k+1)] for i in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    ni = int(n[i])
    for j in range(k+1):
        for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st]

print(sum(dp[l][k]))
