x = int(input(""))
n = int(input(""))
out = int()


def count_zero(temp):
    temp=int(temp)
    if temp != 0:
        return 1
    else:
        return 0


def count(temp):
    cout = int()
    for i in temp:
        cout = cout + count_zero(i)

    return cout

out=0
for i in range(1, x+1):
    temp = str(i)

    if count(temp) == n:
        out=out+1
print(out)