import numpy as np
n = int(input())
k = int(input())
counter = 0
kotae = 0
num = 0
num2 = 0
s = str(num)
char_list = list(s)#文字列をリストに
int_list = int(char_list)

for i in range(n+1):
    num = i
    counter = 0
    if(len(s)<k):
        continue
    else:
        '''
        for j in range(len(s)):
            if(counter>k):
                break
            num2 = num // 10*10
            if(not num-num2==0):
                counter = counter + 1
            num = num//10
        '''
        if(np.count_nonzero(b) ==k):
            kotae = kotae + 1

print(kotae)
