
import math
from functools import reduce
import itertools

nstr = input()
n = int(nstr)
k = int(input())
l = len(nstr)
narr = [int(a) for a in nstr]

combnum = (lambda n, r: math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))

result = 0
if l > k:
  result = combnum(l-1, k) * 9**k
  
result += combnum(l-1, k-1) * ((narr[0]-1) * 9**(k-1))
if k == 1:
  result += 1
else:
  result += sum([reduce(lambda a, b: a*b, c) for c in itertools.combinations(narr[1:], k-1)])
print(result)