def f(n,k):

  if k<1: return 1

  if n<10:

    if k<2: return n

    return 0

  d,m=n//10,n%10

  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k)

print((f(int(eval(input())),int(eval(input())))))
s=eval(input())

n=len(s)

K=int(eval(input()))

dp=[[[0,0] for _ in range(K+1)] for _ in range(n+1)]

dp[0][0][0]=1

r=range

for i in r(n):

  nd=int(s[i])

  for j in r(K+1):

    for k in r(2):

      for d in r(10):

        ni,nj,nk=i+1,j,k

        if d: nj+=1

        if nj>K: continue

        if k<1:

          if d>nd: continue

          if d<nd: nk=1

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

print((dp[n][K][0]+dp[n][K][1]))
def f(n, k):
    if k < 1:
        return 1
    if n < 10:
        if k < 2:
            return n
        return 0
    d, m = n // 10, n % 10
    return f(d, k - 1) * m + f(d - 1, k - 1) * (9 - m) + f(d, k)


print((f(int(eval(input())), int(eval(input())))))

s = eval(input())
n = len(s)
K = int(eval(input()))
dp = [[[0, 0] for _ in range(K + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
r = range
for i in r(n):
    nd = int(s[i])
    for j in r(K + 1):
        for k in r(2):
            for d in r(10):
                ni, nj, nk = i + 1, j, k
                if d:
                    nj += 1
                if nj > K:
                    continue
                if k < 1:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
print((dp[n][K][0] + dp[n][K][1]))

-def f(n, k): -    if k < 1: -        return 1 -    if n < 10: -        if k < 2: -            return n -        return 0 -    d, m = n // 10, n % 10 -    return f(d, k - 1) * m + f(d - 1, k - 1) * (9 - m) + f(d, k) - - -print((f(int(eval(input())), int(eval(input()))))) +s = eval(input()) +n = len(s) +K = int(eval(input())) +dp = [[[0, 0] for _ in range(K + 1)] for _ in range(n + 1)] +dp[0][0][0] = 1 +r = range +for i in r(n): +    nd = int(s[i]) +    for j in r(K + 1): +        for k in r(2): +            for d in r(10): +                ni, nj, nk = i + 1, j, k +                if d: +                    nj += 1 +                if nj > K: +                    continue +                if k < 1: +                    if d > nd: +                        continue +                    if d < nd: +                        nk = 1 +                dp[ni][nj][nk] += dp[i][j][k] +print((dp[n][K][0] + dp[n][K][1]))