import math

s = input()
k = int(input())
r = 0
d = k

def p(n, k):
  return math.factorial(n) // math.factorial(n - k)

def c(n, k):
  if n == 0:
    return 0
  else:
    return p(n, k) // math.factorial(k)

while d <= len(s):
  if d == len(s):
    if k == 1:
      r += int(s[0])
    elif k == 2:
      r += int(s[1]) + (int(s[0]) - 1) * 9 + int(s[0]) * 9 * c(d - 2, 1)
    elif k == 3:
      r += int(s[2]) + (int(s[1]) - 1) * 9 + int(s[1]) * 9 * c(d - 3, 1) + (int(s[0]) - 1) * 81 * c(d - 2, 1) + int(s[0]) * 81 * c(d - 2, 2)
  else:
    if k == 1:
      r += 9
    elif k == 2:
      r += 9 * 9 * c(d - 1, 1)
    elif k == 3:
      r += 9 * 81 * c(d - 1, 2)
  d += 1
    
print(r)