N = int(input())
K = int(input())

let = list(map(int, list(str(N))))
digit = len(let)

if K > digit:
  print(0)
  exit()

def comb(n, k):
  nu = 1
  de = 1
  if n-k < k:
    k = n - k
  for i in range(0,k):
    nu *= n-i
    de *= k-i
  return int(nu/de)

def test(N):
  digit = 1
  arr = [0] * (1 + digit)
  for i in range(1,N + 1):
    cnt = 0
    temp = list(str(i))
    for j in temp:
      if j == "0":
        cnt += 1
    arr[cnt] += 1
    if len(str(i+1)) > digit:
      digit = len(str(i+1))
      print(arr)
      arr = [0] * (1 + digit)
  print(arr)
      
def sum_by_digit_and_K(digit, K):
  temp = 9 ** K 
  res = []
  for i in range(1, digit+1-K):
    res.append(comb(i,K-1) * temp)
  print(res)
  return sum(res)

def solve(N, K, digit, let):
  res = 0
  for i in range(K):
    res += let[i] * sum_by_digit_and_K(digit-i, K-i)
  return res
        
print(solve(N, K, digit, let))
