def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729

N=input()
K=int(input())
D = len(N)
score=0
for i,a in enumerate(N):
  if a!="0":
    score+=calc(int(a),D-i,K)
    K-=1
  if K==0:
    break
print(score) def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 calc if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 K==1 K 1 return a+(D-1)*9 a+(D-1)*9 a (D-1)*9 D-1 D 1 9 elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
   K==2 K 2 return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81 (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81 (a-1)*(D-1)*9 (a-1)*(D-1) a-1 a 1 D-1 D 1 9 (D-1)*(D-2)//2*81 (D-1)*(D-2)//2 (D-1)*(D-2) D-1 D 1 D-2 D 2 2 81 return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 (a-1)*(D-1)*(D-2)//2*81 (a-1)*(D-1)*(D-2)//2 (a-1)*(D-1)*(D-2) (a-1)*(D-1) a-1 a 1 D-1 D 1 D-2 D 2 2 81 (D-1)*(D-2)*(D-3)//6*729 (D-1)*(D-2)*(D-3)//6 (D-1)*(D-2)*(D-3) (D-1)*(D-2) D-1 D 1 D-2 D 2 D-3 D 3 6 729 a a D D K K N=input() N input() input K=int(input()) K int(input()) int input() input D = len(N) D len(N) len N score=0 score 0 for i,a in enumerate(N):
  if a!="0":
    score+=calc(int(a),D-i,K)
    K-=1
  if K==0:
    break i a enumerate(N) enumerate N if a!="0":
    score+=calc(int(a),D-i,K)
    K-=1
   a!="0" a "0" score+=calc(int(a),D-i,K) score calc(int(a),D-i,K) calc int(a) int a D-i D i K K-=1 K 1 if K==0:
    break K==0 K 0 break print(score) print score K-=1 1 K def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729 calc N=input() input() N score=0 0 score K=int(input()) int(input()) K D = len(N) len(N) D score+=calc(int(a),D-i,K) calc(int(a),D-i,K) score
def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729

N=input()
K=int(input())
D = len(N)
score=0
for i,a in enumerate(N):
  if a!="0":
    score+=calc(int(a),D-i,K)
    K-=1
  if K==0:
    break
print(score)