N = int(input())

K = int(input())


cnt_2 = 0
for j in range(N+1):
    cnt_1 = 0
    s = [k for k in str(j)]
    l = len(s)
    for i in range(l):
        if s[i]!='0':
            cnt_1+=1
    if cnt_1==K:
        cnt_2+=1

print(cnt_2)