n = map(int, input())
k = int(input())

dp = [0] * (k+1)
dp[0] = 0
limit_non_zero = 0


for l in n:
  limit_non_zero += (l != 0)
  for i in range(k, 0, -1):
    dp[i] = dp[i-1] * 9 + dp[i]
    if limit_non_zero == i and l > 0:
      dp[i] += l - 1
    elif limit_non_zero -1 == i:
      dp[i] += 1
  dp[0] = 1

print(dp[-1]+ (limit_non_zero == k))