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

ans = 0

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

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

    ans += 1

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

ans = 0

for i in range(1,10):

  for j in range(0,10):

    for k in range(0,10):

      x = 10000*i + 1000*j + 100*k + 10*j + i

      if a <= x <= b:

        ans += 1

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

a, b = list(map(int, input().split()))
ans = 0
for i in range(1, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            x = 10000 * i + 1000 * j + 100 * k + 10 * j + i
            if a <= x <= b:
                ans += 1
print(ans)

-for i in range(a, b + 1): -    if str(i) == str(i)[::-1]: -        ans += 1 +for i in range(1, 10): +    for j in range(0, 10): +        for k in range(0, 10): +            x = 10000 * i + 1000 * j + 100 * k + 10 * j + i +            if a <= x <= b: +                ans += 1