i, j, k = map(int, input().split())
count = 0
for i in range(i, j + 1):
    revi = int(str(i)[::-1])
    if (abs(i - revi) / k).is_integer():
        count += 1
print(count)

dfb03ff95283081c056d858639d364a1b3fbe981
<mask token>

<mask token>
for i in range(i, j + 1):
    revi = int(str(i)[::-1])
    if (abs(i - revi) / k).is_integer():
        count += 1
print(count)

i, j, k = map(int, input().split())
count = 0
for i in range(i, j + 1):
    revi = int(str(i)[::-1])
    if (abs(i - revi) / k).is_integer():
        count += 1
print(count)
