from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,pprint,fractions

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

K = inp()

s = list(str(n))

l = len(s)



dp = [[[0 for _ in range(2)] for j in range(4)] for i in range(l+5)]

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



for i in range(l):

    nd = int(s[i])

    # print(nd)

    for j in range(4):

        for k in range(2):

            for d in range(10):

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

                if d>0: nj += 1

                if nj >= 4: continue



                if k == 0:

                    if d < nd: nk += 1

                    elif d > nd: continue

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

# print(dp)

print((sum(dp[l][K])))
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush

from bisect import bisect_left,bisect_right 

import sys,math,itertools,fractions

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



s = eval(input())

n = len(s)

K = inp()

dp = [[[0 for i in range(5)] for j in range(2)] for k in range(n+1)]

# dp[i][j][k] j:0 kaku j:1 mikaku , k:kosuu

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

for i,x in enumerate(s):

    x = int(x)

    for k in range(4):

        dp[i+1][0][k] += dp[i][0][k]

        dp[i+1][0][k+1] += dp[i][0][k]*9 + dp[i][1][k]*max(0,(x-1))



        if x != 0:

            dp[i+1][0][k] += dp[i][1][k]

            dp[i+1][1][k+1] = dp[i][1][k]

            if k == 0: dp[i+1][1][k] = 0

        else:

            dp[i+1][1][k] = dp[i][1][k] 

        for j in range(2):

            dp[i+1][j][k] %= mod



    # print(dp[i+1][0])

    # print(dp[i+1][1])

    # print()

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

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, pprint, fractions

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
K = inp()
s = list(str(n))
l = len(s)
dp = [[[0 for _ in range(2)] for j in range(4)] for i in range(l + 5)]
dp[0][0][0] = 1
for i in range(l):
    nd = int(s[i])
    # print(nd)
    for j in range(4):
        for k in range(2):
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d > 0:
                    nj += 1
                if nj >= 4:
                    continue
                if k == 0:
                    if d < nd:
                        nk += 1
                    elif d > nd:
                        continue
                dp[ni][nj][nk] += dp[i][j][k]
# print(dp)
print((sum(dp[l][K])))

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


s = eval(input())
n = len(s)
K = inp()
dp = [[[0 for i in range(5)] for j in range(2)] for k in range(n + 1)]
# dp[i][j][k] j:0 kaku j:1 mikaku , k:kosuu
dp[0][1][0] = 1
for i, x in enumerate(s):
    x = int(x)
    for k in range(4):
        dp[i + 1][0][k] += dp[i][0][k]
        dp[i + 1][0][k + 1] += dp[i][0][k] * 9 + dp[i][1][k] * max(0, (x - 1))
        if x != 0:
            dp[i + 1][0][k] += dp[i][1][k]
            dp[i + 1][1][k + 1] = dp[i][1][k]
            if k == 0:
                dp[i + 1][1][k] = 0
        else:
            dp[i + 1][1][k] = dp[i][1][k]
        for j in range(2):
            dp[i + 1][j][k] %= mod
    # print(dp[i+1][0])
    # print(dp[i+1][1])
    # print()
print((dp[-1][0][K] + dp[-1][1][K]))

-from heapq import heappop, heappush, heapify -import sys, bisect, math, itertools, pprint, fractions +from heapq import heappop, heappush +from bisect import bisect_left, bisect_right +import sys, math, itertools, fractions -n = inp() +s = eval(input()) +n = len(s) -s = list(str(n)) -l = len(s) -dp = [[[0 for _ in range(2)] for j in range(4)] for i in range(l + 5)] -dp[0][0][0] = 1 -for i in range(l): -    nd = int(s[i]) -    # print(nd) -    for j in range(4): -        for k in range(2): -            for d in range(10): -                ni = i + 1 -                nj = j -                nk = k -                if d > 0: -                    nj += 1 -                if nj >= 4: -                    continue -                if k == 0: -                    if d < nd: -                        nk += 1 -                    elif d > nd: -                        continue -                dp[ni][nj][nk] += dp[i][j][k] -# print(dp) -print((sum(dp[l][K]))) +dp = [[[0 for i in range(5)] for j in range(2)] for k in range(n + 1)] +# dp[i][j][k] j:0 kaku j:1 mikaku , k:kosuu +dp[0][1][0] = 1 +for i, x in enumerate(s): +    x = int(x) +    for k in range(4): +        dp[i + 1][0][k] += dp[i][0][k] +        dp[i + 1][0][k + 1] += dp[i][0][k] * 9 + dp[i][1][k] * max(0, (x - 1)) +        if x != 0: +            dp[i + 1][0][k] += dp[i][1][k] +            dp[i + 1][1][k + 1] = dp[i][1][k] +            if k == 0: +                dp[i + 1][1][k] = 0 +        else: +            dp[i + 1][1][k] = dp[i][1][k] +        for j in range(2): +            dp[i + 1][j][k] %= mod +    # print(dp[i+1][0]) +    # print(dp[i+1][1]) +    # print() +print((dp[-1][0][K] + dp[-1][1][K]))