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



cnt = 0

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

    n_s = str(n)

    n_s_rvs = n_s[::-1]

    if n_s == n_s_rvs:

        cnt += 1



print(cnt)

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



cnt = 0

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

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

        cnt += 1



print(cnt)

A, B = list(map(int, input().split()))
cnt = 0
for n in range(A, B + 1):
    n_s = str(n)
    n_s_rvs = n_s[::-1]
    if n_s == n_s_rvs:
        cnt += 1
print(cnt)

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

-    n_s = str(n) -    n_s_rvs = n_s[::-1] -    if n_s == n_s_rvs: +    if n // 10000 == n % 10 and (n // 1000) % 10 == (n // 10) % 10: