n = input()
k = int(input())

from math import factorial as f
def ncr(n,r):
  return f(n)//(f(r)*f(n-r)) if n>=r else 0

cnt = 1
l = []
for i in n:
  if int(i) > 0:
    l.append([len(n)-cnt,int(i)-1])
    if len(l) > 2:
      break
  cnt += 1

ans = 1
ans += ncr(l[0][0],k)*(9**k) + l[0][1]*ncr(l[0][0],k-1)*(9**(k-1))
if k>1 and len(l)>1:
  ans += ncr(l[1][0],(k-1))*(9**(k-1)) + l[1][1]*ncr(l[1][0],k-2)*(9**(k-2))
if k>2 and len(l)>2:
  ans += ncr(l[2][0],(k-2))*(9**(k-2)) + l[2][1]*ncr(l[2][0],k-3)*(9**(k-3))
print(ans)
  