import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
K = int(input())

import functools

@functools.lru_cache(None)
def rec(i, k, is_same):
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
    return res

n = len(S)
res = rec(n - 1, K, 1)
print(res) import sys sys import itertools itertools import time time import math math import heapq heapq from collections import defaultdict sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 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 S = input() S input() input K = int(input()) K int(input()) int input() input import functools functools def rec(i, k, is_same):
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
    return res rec if k == 0:
        return 1
     k == 0 k 0 return 1 1 if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

     i == 0 i 0 if k >= 2:
            return 0
         k >= 2 k 2 return 0 0 if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

     is_same == 1 is_same 1 return int(S[len(S) - i - 1]) int(S[len(S) - i - 1]) int S[len(S) - i - 1] S len(S) - i - 1 len(S) - i len(S) len S i 1 return 9 9 res = 0 res 0 a = int(S[len(S) - i - 1]) a int(S[len(S) - i - 1]) int S[len(S) - i - 1] S len(S) - i - 1 len(S) - i len(S) len S i 1 if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
     is_same == 1 is_same 1 for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
     x range(a + 1) range a + 1 a 1 if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
     x == a and x == 0 x == a x a x == 0 x 0 res += rec(i - 1, k, 1) res rec(i - 1, k, 1) rec i - 1 i 1 k 1 elif x == 0:
                res += rec(i - 1, k, 0)
             x == 0 x 0 res += rec(i - 1, k, 0) res rec(i - 1, k, 0) rec i - 1 i 1 k 0 elif x == a:
                res += rec(i - 1, k - 1, 1)
             x == a x a res += rec(i - 1, k - 1, 1) res rec(i - 1, k - 1, 1) rec i - 1 i 1 k - 1 k 1 1 res += rec(i - 1, k - 1, 0) res rec(i - 1, k - 1, 0) rec i - 1 i 1 k - 1 k 1 0 for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
     x range(10) range 10 if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
     x == 0 x 0 res += rec(i - 1, k, 0) res rec(i - 1, k, 0) rec i - 1 i 1 k 0 res += rec(i - 1, k - 1, 0) res rec(i - 1, k - 1, 0) rec i - 1 i 1 k - 1 k 1 0 return res res i i k k is_same is_same @functools.lru_cache(None) rec None @functools.lru_cache(None) functools.lru_cache None rec n = len(S) n len(S) len S res = rec(n - 1, K, 1) res rec(n - 1, K, 1) rec n - 1 n 1 K 1 print(res) print res S = input() input() S MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD read = sys.stdin.buffer.read sys.stdin.buffer.read read n = len(S) len(S) n K = int(input()) int(input()) K res = rec(n - 1, K, 1) rec(n - 1, K, 1) res readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines def rec(i, k, is_same):
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
    return res def rec(i, k, is_same):
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
    return res rec INF = 10 ** 18 10 ** 18 INF readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
K = int(input())

import functools

@functools.lru_cache(None)
def rec(i, k, is_same):
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            return int(S[len(S) - i - 1])
        else:
            return 9

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)
    return res

n = len(S)
res = rec(n - 1, K, 1)
print(res)