import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    K = int(input())

    counter = [0, 0, 0, 0]
    for i in range(1, N+1):
        cnt = len(str(i)) - str(i).count('0')
        if cnt <= 3:
            counter[cnt] += 1
    print(counter[K])


if __name__ == '__main__':
    resolve()
