a,b = list(map(int, input().split()))

n = 0

for i in range(a, b + 1):

    f = True

    s = str(i)

    l = len(s)

    for j in range(l//2 + 1):

        if s[j] != s[- j - 1]:

            f = False

            break

    if f:

        n += 1

print(n)
a,b = list(map(int, input().split()))

n = 0

for i in range(1, 10):

    for j in range(10):

        for k in range(10):

            s = 10000 * i + 1000 * j + 100 * k + 10 * j + i

            if a <= s <= b:

                n += 1

print(n)
a, b = list(map(int, input().split()))
n = 0
for i in range(a, b + 1):
    f = True
    s = str(i)
    l = len(s)
    for j in range(l // 2 + 1):
        if s[j] != s[-j - 1]:
            f = False
            break
    if f:
        n += 1
print(n)

a, b = list(map(int, input().split()))
n = 0
for i in range(1, 10):
    for j in range(10):
        for k in range(10):
            s = 10000 * i + 1000 * j + 100 * k + 10 * j + i
            if a <= s <= b:
                n += 1
print(n)

-for i in range(a, b + 1): -    f = True -    s = str(i) -    l = len(s) -    for j in range(l // 2 + 1): -        if s[j] != s[-j - 1]: -            f = False -            break -    if f: -        n += 1 +for i in range(1, 10): +    for j in range(10): +        for k in range(10): +            s = 10000 * i + 1000 * j + 100 * k + 10 * j + i +            if a <= s <= b: +                n += 1