# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7   
N = readline().decode().rstrip()
K = int(readline())
L = len(N)
# 桁DP
dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1)]
dp[0][0][0] = 1
for i in range(L):
    for j in range(4):
        for k in range(2):
            nd = int(N[i])
            for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
print(dp[L][K][0]+dp[L][K][1]) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 N = readline().decode().rstrip() N readline().decode().rstrip() ().decode().rstrip ().decode() ().decode () readline decode rstrip K = int(readline()) K int(readline()) int readline() readline L = len(N) L len(N) len N [[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1) for _ in range(L+1) _ range(L+1) range L+1 L 1 for _ in range(L+1) [[0 for _ in range(2)] for _ in range(4)] dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1)] dp [[[0 for _ in range(2)] for _ in range(4)] for _ 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):
    for j in range(4):
        for k in range(2):
            nd = int(N[i])
            for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k] i range(L) range L for j in range(4):
        for k in range(2):
            nd = int(N[i])
            for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k] j range(4) range 4 for k in range(2):
            nd = int(N[i])
            for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k] k range(2) range 2 nd = int(N[i]) nd int(N[i]) int N[i] N i for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k] d range(10) range 10 ni = i + 1 ni i + 1 i 1 nj = j nj j nk = k nk k if d != 0:
                    nj += 1
                 d != 0 d 0 nj += 1 nj 1 if nj > K:
                    continue
                 nj > K nj K continue if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                 k == 0 k 0 if d > nd:
                        continue
                     d > nd d nd continue if d < nd:
                        nk = 1
                 d < nd d nd nk = 1 nk 1 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[L][K][0]+dp[L][K][1]) print dp[L][K][0]+dp[L][K][1] dp[L][K][0] [K] [L] dp L K 0 dp[L][K][1] [K] [L] dp L K 1 K = int(readline()) int(readline()) K readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines nj += 1 1 nj N = readline().decode().rstrip() readline().decode().rstrip() N nj = j j nj nk = 1 1 nk nd = int(N[i]) int(N[i]) nd nk = k k nk readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline MOD = 10**9+7 10**9+7 MOD L = len(N) len(N) L dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1)] [[[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1)] dp ni = i + 1 i + 1 ni read = sys.stdin.buffer.read sys.stdin.buffer.read read
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7   
N = readline().decode().rstrip()
K = int(readline())
L = len(N)
# 桁DP
dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(L+1)]
dp[0][0][0] = 1
for i in range(L):
    for j in range(4):
        for k in range(2):
            nd = int(N[i])
            for d in range(10):
                ni = i + 1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
print(dp[L][K][0]+dp[L][K][1])