counter = 0

c = list(map(int, input().split(' ')))

for i in range(c[0], c[1] + 1):

  if str(i)[0] != str(i)[4]:

    continue

  if str(i)[1] != str(i)[3]:

    continue

  counter += 1



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

counter = 0

for i in range(a[0], a[1] + 1):

  stri = str(i)

  if (stri[0] == stri[4] and stri[1] == stri[3]):

    counter += 1

    

print(counter)
counter = 0
c = list(map(int, input().split(" ")))
for i in range(c[0], c[1] + 1):
    if str(i)[0] != str(i)[4]:
        continue
    if str(i)[1] != str(i)[3]:
        continue
    counter += 1
print(counter)

a = list(map(int, input().split()))
counter = 0
for i in range(a[0], a[1] + 1):
    stri = str(i)
    if stri[0] == stri[4] and stri[1] == stri[3]:
        counter += 1
print(counter)

+a = list(map(int, input().split())) -c = list(map(int, input().split(" "))) -for i in range(c[0], c[1] + 1): -    if str(i)[0] != str(i)[4]: -        continue -    if str(i)[1] != str(i)[3]: -        continue -    counter += 1 +for i in range(a[0], a[1] + 1): +    stri = str(i) +    if stri[0] == stri[4] and stri[1] == stri[3]: +        counter += 1