i1 = input()
i2 = input()
num = int(i2)
st = ''
for n in range(0 ,int(i2)):
    st += '1'
st_n = int(st)
    
c = 0
for n in range(st_n, int(i1)+1):
    st = str(n)
    st_sp = st.split('0')
    if((len(st)-len(st_sp)+1)==num):
        c+=1
    
print(c)