s = input()
ind = len(n)
n = int(s)

k = int(input())

memo = [[None]*(k+1) for _ in range(ind+1)]

memo[1][1] = 9
memo[1][2] = 0
memo[1][3] = 0

for i in range(2,ind+1):
  for j in range(k+1):
    if j == 0:
      ans == 1
    elif i<j:
      ans == 0
    elif i+j==n:
      ans = int(s[n-i])*memo[i-1][j-1] + memo[i-1][j]
    else:
      ans = 9*memo[i-1][j-1] + memo[i-1][j]
    memo[i][j] = ans
    
print(memo[ind][k])




