<gh_stars>0
#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the beautifulDays function below.
def beautifulDays(i, j, k):
    beautifulDays = 0
    for a in range(i, j+1):
        beautifulDays = beautifulDays + abs(not (a - int(str(a)[::-1]))%k)
    return beautifulDays
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    ijk = input().split()

    i = int(ijk[0])

    j = int(ijk[1])

    k = int(ijk[2])

    result = beautifulDays(i, j, k)

    fptr.write(str(result) + '\n')

    fptr.close()

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the beautifulDays function below.
def beautifulDays(i, j, k):
    beautifulDays = 0
    for a in range(i, j+1):
        beautifulDays = beautifulDays + abs(not (a - int(str(a)[::-1]))%k)
    return beautifulDays
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    ijk = input().split()

    i = int(ijk[0])

    j = int(ijk[1])

    k = int(ijk[2])

    result = beautifulDays(i, j, k)

    fptr.write(str(result) + '\n')

    fptr.close()
#!/bin/python3 # Complete the beautifulDays function below.