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

count = 0

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

  i = str(i)

  if i[0] == i[-1] and i[1] == i[-2]:

    count +=1

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



count = 0

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

	s = str(i)

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

		count += 1

print(count)

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

A, B = list(map(int, input().split()))
count = 0
for i in range(A, B + 1):
    s = str(i)
    if s[0] == s[4] and s[1] == s[3]:
        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): -    i = str(i) -    if i[0] == i[-1] and i[1] == i[-2]: +for i in range(A, B + 1): +    s = str(i) +    if s[0] == s[4] and s[1] == s[3]: