import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = list(input())
K = int(input())
length = len(N)

dp = [[[0]*2 for _ in range(K+1)] for _ in range(length+1)]
dp[0][0][1] = 1
for i in range(length):
    n = int(N[i])
    for k in range(K+1):
        if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
        for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0]
print(sum(dp[-1][K])) import sys sys def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) mapint sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 N = list(input()) N list(input()) list input() input K = int(input()) K int(input()) int input() input length = len(N) length len(N) len N [[0]*2 for _ in range(K+1)] for _ in range(length+1) for _ in range(length+1) _ range(length+1) range length+1 length 1 for _ in range(length+1) [[0]*2 for _ in range(K+1)] dp = [[[0]*2 for _ in range(K+1)] for _ in range(length+1)] dp [[[0]*2 for _ in range(K+1)] for _ in range(length+1)] dp[0][0][1] = 1 dp[0][0][1] [0] [0] dp 0 0 1 1 for i in range(length):
    n = int(N[i])
    for k in range(K+1):
        if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
        for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0] i range(length) range length n = int(N[i]) n int(N[i]) int N[i] N i for k in range(K+1):
        if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
        for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0] k range(K+1) range K+1 K 1 if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
         k==K k K dp[i+1][k][0]+=dp[i][k][0] dp[i+1][k][0] [k] [i+1] dp i+1 i 1 k 0 dp[i][k][0] [k] [i] dp i k 0 if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
             n==0 n 0 dp[i+1][k][1]+=dp[i][k][1] dp[i+1][k][1] [k] [i+1] dp i+1 i 1 k 1 dp[i][k][1] [k] [i] dp i k 1 dp[i+1][k][0]+=dp[i][k][1] dp[i+1][k][0] [k] [i+1] dp i+1 i 1 k 0 dp[i][k][1] [k] [i] dp i k 1 continue for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0] j range(10) range 10 if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0] j==0 j 0 if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
             n==0 n 0 dp[i+1][k][0]+=dp[i][k][0] dp[i+1][k][0] [k] [i+1] dp i+1 i 1 k 0 dp[i][k][0] [k] [i] dp i k 0 dp[i+1][k][1]+=dp[i][k][1] dp[i+1][k][1] [k] [i+1] dp i+1 i 1 k 1 dp[i][k][1] [k] [i] dp i k 1 dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1] dp[i+1][k][0] [k] [i+1] dp i+1 i 1 k 0 dp[i][k][0]+dp[i][k][1] dp[i][k][0] [k] [i] dp i k 0 dp[i][k][1] [k] [i] dp i k 1 elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
             j==n j n dp[i+1][k+1][1]+=dp[i][k][1] dp[i+1][k+1][1] [k+1] [i+1] dp i+1 i 1 k+1 k 1 1 dp[i][k][1] [k] [i] dp i k 1 dp[i+1][k+1][0]+=dp[i][k][0] dp[i+1][k+1][0] [k+1] [i+1] dp i+1 i 1 k+1 k 1 0 dp[i][k][0] [k] [i] dp i k 0 elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
             j<n j n dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1] dp[i+1][k+1][0] [k+1] [i+1] dp i+1 i 1 k+1 k 1 0 dp[i][k][0]+dp[i][k][1] dp[i][k][0] [k] [i] dp i k 0 dp[i][k][1] [k] [i] dp i k 1 dp[i+1][k+1][0]+=dp[i][k][0] dp[i+1][k+1][0] [k+1] [i+1] dp i+1 i 1 k+1 k 1 0 dp[i][k][0] [k] [i] dp i k 0 print(sum(dp[-1][K])) print sum(dp[-1][K]) sum dp[-1][K] [-1] dp -1 K N = list(input()) list(input()) N def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) def mapint(): return map(int, input().split()) mapint dp = [[[0]*2 for _ in range(K+1)] for _ in range(length+1)] [[[0]*2 for _ in range(K+1)] for _ in range(length+1)] dp length = len(N) len(N) length K = int(input()) int(input()) K n = int(N[i]) int(N[i]) n
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = list(input())
K = int(input())
length = len(N)

dp = [[[0]*2 for _ in range(K+1)] for _ in range(length+1)]
dp[0][0][1] = 1
for i in range(length):
    n = int(N[i])
    for k in range(K+1):
        if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
        for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0]
print(sum(dp[-1][K]))