import math
fac = math.factorial
n = int(input())
K = int(input())
lst = []
cnt = 0
for i in range(10**(K-1), 10**K):
  if str(i).count("0") != 0:
    continue
  lst.append(list(map(int, list(str(i)))))
if K == 1:
  for i in range(100-K):
    for lsti in lst:
      if lsti * 10 ** i <= n:
        cnt += 1
elif K == 2:
  for i in range(1, 100-K):
    for j in range(100-K-i):
      for lsti in lst:
        if lsti[0] * 10 ** (i+j) \
             + lsti[1] * 10 ** j <= n:
          cnt += 1
elif K == 3:
  for i in range(2, 100-K):
    for j in range(1, 100-K-i):
      for k in range(100-K-i-j):
        for lsti in lst:
          if lsti[0] * 10 ** (i+j+k) \
             + lsti[1] * 10 ** (j+k) \
             + lsti[2] * 10 ** k <= n:
            cnt += 1
print(cnt)