n, m = list(map(int, input().split()))

ans = 0

for i in range(n, m+1):

    if str(i)[0]+str(i)[1] == str(i)[-1]+str(i)[-2]: ans += 1

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

ans = 0

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

    if str(n) == str(n)[::-1]: ans += 1

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

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

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