def f(n, k):
    count = 0
    for i in range(1, n+1):
        s = str(i)
        count_not_zero = 0
        for j in s:
            if j != '0':
                count_not_zero += 1
            if count_not_zero > k:
                break
        else:
            if count_not_zero == k:
                count += 1
    print(count)


n = int(input())
k = int(input())
f(n, k)
