import sys
input = sys.stdin.readline

def main():
  n = int(input())
  k = int(input())

  _list = [i for i in range(1, n+1)]
  
  count = 0
  for i in _list:
    tmp = str(i)
    if len(tmp) - tmp.count('0') == k:
      count += 1

  print(count)

if __name__ == '__main__':
    main()