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

cnt = 0

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

    X = str(x)

    if X == X[::-1]:

        cnt += 1

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

cnt = 0

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

  x = str(i)

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

    cnt += 1

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

A, B = list(map(int, input().split()))
cnt = 0
for i in range(A, B + 1):
    x = str(i)
    if x[0] == x[4] and x[1] == x[3]:
        cnt += 1
print(cnt)

-for x in range(A, B + 1): -    X = str(x) -    if X == X[::-1]: +for i in range(A, B + 1): +    x = str(i) +    if x[0] == x[4] and x[1] == x[3]: