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

total = 0

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

  if i == int(str(i)[::-1]):

    total += 1

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

total = 0

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

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

    total += 1

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

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

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