import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

n, k = map(int, read().split())


@lru_cache()
def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt


print(check(n, k)) 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 sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from functools import lru_cache n, k = map(int, read().split()) n map(int, read().split()) map int read().split() ().split () read split k def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt check if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
     n < 10 n 10 if k == 0:
            return 1
         k == 0 k 0 return 1 1 if k == 1:
            return n
         k == 1 k 1 return n n return 0 0 a, b = divmod(n, 10) a divmod(n, 10) divmod n 10 b cnt = 0 cnt 0 if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
     k >= 1 k 1 cnt += check(a, k - 1) * b cnt check(a, k - 1) * b check(a, k - 1) check a k - 1 k 1 b cnt += check(a - 1, k - 1) * (9 - b) cnt check(a - 1, k - 1) * (9 - b) check(a - 1, k - 1) check a - 1 a 1 k - 1 k 1 9 - b 9 b cnt += check(a, k) cnt check(a, k) check a k return cnt cnt n n k k @lru_cache() check lru_cache check print(check(n, k)) print check(n, k) check n k read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline n, k = map(int, read().split()) map(int, read().split()) n def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt check k = map(int, read().split()) map(int, read().split()) k
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

n, k = map(int, read().split())


@lru_cache()
def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt


print(check(n, k))
