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

count = 0



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

    target = str(i)

    if target == target[::-1]:

        count += 1



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

count = 0



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

    if i//10000 == (i//1) % 10 and (i//1000) % 10 == (i//10) % 10:

        count += 1



print(count)
a, b = list(map(int, input().split()))
count = 0
for i in range(a, b + 1):
    target = str(i)
    if target == target[::-1]:
        count += 1
print(count)

a, b = list(map(int, input().split()))
count = 0
for i in range(a, b + 1):
    if i // 10000 == (i // 1) % 10 and (i // 1000) % 10 == (i // 10) % 10:
        count += 1
print(count)

-    target = str(i) -    if target == target[::-1]: +    if i // 10000 == (i // 1) % 10 and (i // 1000) % 10 == (i // 10) % 10: