N = int(input())
K = int(input())
ans = 0

if K == 1:
  ans += 9 * (len(str(N))-1) + int(str(N)[0])
else:
  for i in range(N):
    if len(str(i+1)) - list(str(i+1)).count('0') == K:
      ans += 1

print(ans)