def comb(n, k):
  if 0 <= k <= n:
    c = 1
    for i in range(k):
      c *= n-i
      c //= i+1
    return c
  else:
    return 0

n = [int(i) for i in input()]
l = len(n)
k = int(input())
count = 0
for i in range(min(l, k+1)):
  count += 9 ** (k-i) * comb(l-i-1, k-i)
  count += 9 ** (k-i-1) * comb(l-i-1, k-i-1) * (n[i]-1)
print(count)