n=int(input(""))

no=int(input(""))
def has0(x):
    out=int()
    out=0
    while (x != 0):


        if (x % 10 != 0):
            out=out+1

        x = x // 10

    return out


def getCount(n):
    count = 0

    out = int()
    out = 0
    for i in range(1, n + 1):
        count = has0(i)
        if count == no:
            out=out + 1

    return out


print( getCount(n))


