# -*- coding: utf-8 -*-
n = int(input())
k = int(input())

c=0
for i in range(1, n+1):
        #print(i)
        si=str(i)
        if (len(si) - si.count('0')) == k:
                #print(i)
                c+=1
print(c)