#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import factorial

def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)])

if __name__=='__main__':
  main()


 from math import factorial def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)]) main s = list(map(int, input().strip())) s list(map(int, input().strip())) list map(int, input().strip()) map int input().strip() ().strip () input strip k = int(input()) k int(input()) int input() input dp = [] dp [] [0]*(len(s)+1) for _ in range(k+1) for _ in range(k+1) _ range(k+1) range k+1 k 1 for _ in range(k+1) [0]*(len(s)+1) [0] 0 len(s)+1 len(s) len s 1 dp.append([[0]*(len(s)+1) for _ in range(k+1)]) dp.append dp append [[0]*(len(s)+1) for _ in range(k+1)] [0]*(len(s)+1) for _ in range(k+1) for _ in range(k+1) _ range(k+1) range k+1 k 1 for _ in range(k+1) [0]*(len(s)+1) [0] 0 len(s)+1 len(s) len s 1 dp.append([[0]*(len(s)+1) for _ in range(k+1)]) dp.append dp append [[0]*(len(s)+1) for _ in range(k+1)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
   i c enumerate(s) enumerate s for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
   j range(k+1) range k+1 k 1 for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
   d range(10) range 10 nj = j nj j if d != 0:
            nj+=1
           d != 0 d 0 nj+=1 nj 1 if nj > k:
            continue
            
           nj > k nj k continue if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
           d < c d c dp[1][nj][i+1] += dp[0][j][i] dp[1][nj][i+1] [nj] [1] dp 1 nj i+1 i 1 dp[0][j][i] [j] [0] dp 0 j i if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
           d == c d c dp[0][nj][i+1] += dp[0][j][i] dp[0][nj][i+1] [nj] [0] dp 0 nj i+1 i 1 dp[0][j][i] [j] [0] dp 0 j i dp[1][nj][i+1] += dp[1][j][i] dp[1][nj][i+1] [nj] [1] dp 1 nj i+1 i 1 dp[1][j][i] [j] [1] dp 1 j i print(dp[0][k][len(s)]+dp[1][k][len(s)]) print dp[0][k][len(s)]+dp[1][k][len(s)] dp[0][k][len(s)] [k] [0] dp 0 k len(s) len s dp[1][k][len(s)] [k] [1] dp 1 k len(s) len s if __name__=='__main__':
  main() __name__=='__main__' __name__ '__main__' main() main def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)]) def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)]) main
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import factorial

def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)])

if __name__=='__main__':
  main()



