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

count = 0

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

    s = str(i)

    if s[0] == s[4] and s[1] == s[3]:

        count += 1

    else:

        pass

print(count)

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

count = 0

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

    if i//10000 == i%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):
    s = str(i)
    if s[0] == s[4] and s[1] == s[3]:
        count += 1
    else:
        pass
print(count)

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

-    s = str(i) -    if s[0] == s[4] and s[1] == s[3]: +    if i // 10000 == i % 10 and i // 1000 % 10 == i // 10 % 10: -    else: -        pass