N = int(eval(input()))

K = int(eval(input()))

l = len(str(N))

dp = [[[0]*(K+1) for _ in range(2)] for _ in range(l+1)]

# dp[i][smaller][j]

# i: 調べている桁

# smaller: 未満フラグ(未満のとき1)

# j: 0以外の数がj回出た



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

for i in range(l):

  n = int(str(N)[i])

  for j in range(2):

    for k in range(K+1):

      for m in range(10):

        # 今までは一致

        if j == 0 and m > n:

          continue

        if j == 0 and m == n:

          nj = 0 # 今回も一致

          if m == 0:

            nk = k # 0なら回数は増えない

          else:

            if k < K:

              nk = k + 1 # 0以外の数がK-1回以下しかでていないなら増やす

            else:

              nk = k

              continue

        if j == 0 and m < n:

          nj = 1

          if m == 0:

            nk = k

          else:

            if k < K:

              nk = k + 1

            else:

              nk = k

              continue



        # すでに未満

        if j == 1:

          nj = j

          if m == 0:

            nk = k

          else:

            if k < K:

              nk = k + 1

            else:

              nk = k

              continue



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



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



N = str(eval(input()))

K = int(eval(input()))



dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)]

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



for i in range(len(N)):

  n = int(N[i])

  for j in range(K+1):

    for k in range(2): # smaller(未満なら1)

      for l in range(10): 

        nj, nk = j, 0

        if k == 0 and l == n:

          nk = 0

        elif k == 0 and l < n:

          nk = 1

        elif k == 0 and l > n:

          continue

        

        if k == 1:

          nk = 1

        

        if l != 0:

          if j < K:

            nj += 1

          else:

            continue

        

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



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





        

N = int(eval(input()))
K = int(eval(input()))
l = len(str(N))
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(l + 1)]
# dp[i][smaller][j]
# i: 調べている桁
# smaller: 未満フラグ(未満のとき1)
# j: 0以外の数がj回出た
dp[0][0][0] = 1
for i in range(l):
    n = int(str(N)[i])
    for j in range(2):
        for k in range(K + 1):
            for m in range(10):
                # 今までは一致
                if j == 0 and m > n:
                    continue
                if j == 0 and m == n:
                    nj = 0  # 今回も一致
                    if m == 0:
                        nk = k  # 0なら回数は増えない
                    else:
                        if k < K:
                            nk = k + 1  # 0以外の数がK-1回以下しかでていないなら増やす
                        else:
                            nk = k
                            continue
                if j == 0 and m < n:
                    nj = 1
                    if m == 0:
                        nk = k
                    else:
                        if k < K:
                            nk = k + 1
                        else:
                            nk = k
                            continue
                # すでに未満
                if j == 1:
                    nj = j
                    if m == 0:
                        nk = k
                    else:
                        if k < K:
                            nk = k + 1
                        else:
                            nk = k
                            continue
                dp[i + 1][nj][nk] += dp[i][j][k]
print((dp[l][0][K] + dp[l][1][K]))

N = str(eval(input()))
K = int(eval(input()))
dp = [[[0] * 2 for _ in range(K + 1)] for _ in range(len(N) + 1)]
dp[0][0][0] = 1
for i in range(len(N)):
    n = int(N[i])
    for j in range(K + 1):
        for k in range(2):  # smaller(未満なら1)
            for l in range(10):
                nj, nk = j, 0
                if k == 0 and l == n:
                    nk = 0
                elif k == 0 and l < n:
                    nk = 1
                elif k == 0 and l > n:
                    continue
                if k == 1:
                    nk = 1
                if l != 0:
                    if j < K:
                        nj += 1
                    else:
                        continue
                dp[i + 1][nj][nk] += dp[i][j][k]
print((dp[-1][K][0] + dp[-1][K][1]))

-N = int(eval(input())) +N = str(eval(input())) -l = len(str(N)) -dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(l + 1)] -# dp[i][smaller][j] -# i: 調べている桁 -# smaller: 未満フラグ(未満のとき1) -# j: 0以外の数がj回出た +dp = [[[0] * 2 for _ in range(K + 1)] for _ in range(len(N) + 1)] -for i in range(l): -    n = int(str(N)[i]) -    for j in range(2): -        for k in range(K + 1): -            for m in range(10): -                # 今までは一致 -                if j == 0 and m > n: +for i in range(len(N)): +    n = int(N[i]) +    for j in range(K + 1): +        for k in range(2):  # smaller(未満なら1) +            for l in range(10): +                nj, nk = j, 0 +                if k == 0 and l == n: +                    nk = 0 +                elif k == 0 and l < n: +                    nk = 1 +                elif k == 0 and l > n: -                if j == 0 and m == n: -                    nj = 0  # 今回も一致 -                    if m == 0: -                        nk = k  # 0なら回数は増えない +                if k == 1: +                    nk = 1 +                if l != 0: +                    if j < K: +                        nj += 1 -                        if k < K: -                            nk = k + 1  # 0以外の数がK-1回以下しかでていないなら増やす -                        else: -                            nk = k -                            continue -                if j == 0 and m < n: -                    nj = 1 -                    if m == 0: -                        nk = k -                    else: -                        if k < K: -                            nk = k + 1 -                        else: -                            nk = k -                            continue -                # すでに未満 -                if j == 1: -                    nj = j -                    if m == 0: -                        nk = k -                    else: -                        if k < K: -                            nk = k + 1 -                        else: -                            nk = k -                            continue +                        continue -print((dp[l][0][K] + dp[l][1][K])) +print((dp[-1][K][0] + dp[-1][K][1]))