while True:
    try:
        ran, num = input().split()
        res = 0
        for i in range(1, int(ran) + 1):
            temp = list(str(i))
            res += temp.count(num)
        print(res)
    except:
        break