import sys
import math
from itertools import combinations, permutations
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, read().split())
l = len(str(N))
ll = list(range(l))

ans = 0
for v in combinations(ll, K):
    if v[0] != 0:
        ans += 9**K
    if len(v) >= 2:
        if v[0] == 0 and v[1] != 1:
            ans += int(str(N)[0]) * 9**(K - 1)
        else:
            ans += (int(str(N)[0]) - 1) * 9**(K - 1)
            ans += int(str(N)[1]) - 1

print(ans)
