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

count = 0

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

  b1 = i%10

  s = i//10

  b2 = s%10

  t = s//10

  u = t//10

  a2 = u%10

  v = u//10

  a1 = v%10

  if a1 == b1 and a2 == b2:

    count += 1

print(count)
A, B = list(map(int, input().split()))

count = 0

for n in range(A, B+1):

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

    count += 1

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

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

-a, b = list(map(int, input().split())) +A, B = list(map(int, input().split())) -for i in range(a, b + 1): -    b1 = i % 10 -    s = i // 10 -    b2 = s % 10 -    t = s // 10 -    u = t // 10 -    a2 = u % 10 -    v = u // 10 -    a1 = v % 10 -    if a1 == b1 and a2 == b2: +for n in range(A, B + 1): +    if n // 10000 == n % 10 and (n // 1000) % 10 == (n // 10) % 10: