input = 416

ctr = 100000000000 + input
sol = 0
while ctr < 1000000000000:
    if ctr%10000000000 == 0:
        print(".", end='')
    if ctr % input == 0:
        if str(ctr)[-3:] == str(input):
            sum = 0
            for c in str(ctr):
                sum = sum + int(c)
            if input % sum == 0:
                sol =sol + 1
    ctr = ctr + 1000
print(sol)