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



count = 0

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

    listed_i = list(str(i))

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

        count += 1



print(count)

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



count = 0

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

    s = i // 10000

    t = (i % 10000) // 1000

    u = (i % 100) //  10

    v = i % 10

    if s == v and t == u:

        count += 1

print(count)

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

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

-    listed_i = list(str(i)) -    if listed_i[0] == listed_i[4] and listed_i[1] == listed_i[3]: +    s = i // 10000 +    t = (i % 10000) // 1000 +    u = (i % 100) // 10 +    v = i % 10 +    if s == v and t == u: