import sys

from bisect import bisect_left as bi_l, bisect_right as bi_r



a, b = list(map(int, sys.stdin.readline().split()))



def main():

    palindromic_nums = []

    for i in range(1, 10):

        for j in range(10):

            for k in range(10):

                x = [i, j, k, j, i]

                palindromic_nums.append(int(''.join(list(map(str, x)))))



    return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a)

                

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys



def cnt(n):

    m = str(n)

    l = len(m)

    if l == 1: return n + 1

    tot = 0

    tot += pow(10, (l - 1) // 2) * (int(m[0]) - 1)

    tot += pow(10, l // 2) - 1 - 9 * pow(10, l // 2 - 1) * (l & 1 ^ 1)

    while l >= 2:

        l -= 2

        if l == 0: tot += m[1] >= m[0]

        elif l == 1: tot += int(m[1]) + 1 - (m[-1] < m[0])

        else:

            m = str(int(m[1:-1]) - (m[-1] < m[0]))

            m = '0' * (l - len(m)) + m

            tot += int(m[0]) * pow(10, (l - 1) // 2)

    return tot



a, b = list(map(int, sys.stdin.readline().split()))



def main():

    print((cnt(b) - cnt(a-1)))



if __name__ ==  '__main__':

    main()
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r

a, b = list(map(int, sys.stdin.readline().split()))


def main():
    palindromic_nums = []
    for i in range(1, 10):
        for j in range(10):
            for k in range(10):
                x = [i, j, k, j, i]
                palindromic_nums.append(int("".join(list(map(str, x)))))
    return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a)


if __name__ == "__main__":
    ans = main()
    print(ans)

import sys


def cnt(n):
    m = str(n)
    l = len(m)
    if l == 1:
        return n + 1
    tot = 0
    tot += pow(10, (l - 1) // 2) * (int(m[0]) - 1)
    tot += pow(10, l // 2) - 1 - 9 * pow(10, l // 2 - 1) * (l & 1 ^ 1)
    while l >= 2:
        l -= 2
        if l == 0:
            tot += m[1] >= m[0]
        elif l == 1:
            tot += int(m[1]) + 1 - (m[-1] < m[0])
        else:
            m = str(int(m[1:-1]) - (m[-1] < m[0]))
            m = "0" * (l - len(m)) + m
            tot += int(m[0]) * pow(10, (l - 1) // 2)
    return tot


a, b = list(map(int, sys.stdin.readline().split()))


def main():
    print((cnt(b) - cnt(a - 1)))


if __name__ == "__main__":
    main()

-from bisect import bisect_left as bi_l, bisect_right as bi_r + + +def cnt(n): +    m = str(n) +    l = len(m) +    if l == 1: +        return n + 1 +    tot = 0 +    tot += pow(10, (l - 1) // 2) * (int(m[0]) - 1) +    tot += pow(10, l // 2) - 1 - 9 * pow(10, l // 2 - 1) * (l & 1 ^ 1) +    while l >= 2: +        l -= 2 +        if l == 0: +            tot += m[1] >= m[0] +        elif l == 1: +            tot += int(m[1]) + 1 - (m[-1] < m[0]) +        else: +            m = str(int(m[1:-1]) - (m[-1] < m[0])) +            m = "0" * (l - len(m)) + m +            tot += int(m[0]) * pow(10, (l - 1) // 2) +    return tot + -    palindromic_nums = [] -    for i in range(1, 10): -        for j in range(10): -            for k in range(10): -                x = [i, j, k, j, i] -                palindromic_nums.append(int("".join(list(map(str, x))))) -    return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a) +    print((cnt(b) - cnt(a - 1))) -    ans = main() -    print(ans) +    main()