import math

N = input()
K = int(input())

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

answer = 0
len_N = len(N)
# 最上位桁
for i in range(min(3, len(N), K)):
    if len_N > K:
        answer += combinations_count(len(N) - (i + 1), K - i) * (9 ** (K - i))
    answer += combinations_count(len(N) - (i + 1), K - (i + 1)) * (9 ** (K - (i + 1))) * max(0, int(N[i]) - 1)

print(answer + 1)