#!/bin/python3

import sys

def beautifulDays(i, j, k):
    count = 0
    for a in range(i, j):
        original = a
        reversed = int(str(a)[::-1])
        diff = abs(reversed - original)
        if (diff % k) == 0:
            count += 1
    return count

if __name__ == "__main__":
    i, j, k = input().strip().split(' ')
    i, j, k = [int(i), int(j), int(k)]
    result = beautifulDays(i, j, k)
    print(result)

a0510352bda9da5d51180a31aa7be0201c7a6e01
<mask token>

<mask token>


def beautifulDays(i, j, k):
    count = 0
    for a in range(i, j):
        original = a
        reversed = int(str(a)[::-1])
        diff = abs(reversed - original)
        if diff % k == 0:
            count += 1
    return count


<mask token>

<mask token>


def beautifulDays(i, j, k):
    count = 0
    for a in range(i, j):
        original = a
        reversed = int(str(a)[::-1])
        diff = abs(reversed - original)
        if diff % k == 0:
            count += 1
    return count


if __name__ == '__main__':
    i, j, k = input().strip().split(' ')
    i, j, k = [int(i), int(j), int(k)]
    result = beautifulDays(i, j, k)
    print(result)

import sys


def beautifulDays(i, j, k):
    count = 0
    for a in range(i, j):
        original = a
        reversed = int(str(a)[::-1])
        diff = abs(reversed - original)
        if diff % k == 0:
            count += 1
    return count


if __name__ == '__main__':
    i, j, k = input().strip().split(' ')
    i, j, k = [int(i), int(j), int(k)]
    result = beautifulDays(i, j, k)
    print(result)

#!/bin/python3

import sys

def beautifulDays(i, j, k):
    count = 0
    for a in range(i, j):
        original = a
        reversed = int(str(a)[::-1])
        diff = abs(reversed - original)
        if (diff % k) == 0:
            count += 1
    return count

if __name__ == "__main__":
    i, j, k = input().strip().split(' ')
    i, j, k = [int(i), int(j), int(k)]
    result = beautifulDays(i, j, k)
    print(result)
