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

cnt = 0

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

    s = str(x)

    l = len(s)

    flg = True

    for i in range(l // 2):

        if s[i] != s[l - 1 - i]:

            flg = False

            break

    if flg:

        cnt += 1

print(cnt)

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

cnt = 0

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

    s = str(i)

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

        cnt += 1

print(cnt)
a, b = list(map(int, input().split()))
cnt = 0
for x in range(a, b + 1):
    s = str(x)
    l = len(s)
    flg = True
    for i in range(l // 2):
        if s[i] != s[l - 1 - i]:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)

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

-for x in range(a, b + 1): -    s = str(x) -    l = len(s) -    flg = True -    for i in range(l // 2): -        if s[i] != s[l - 1 - i]: -            flg = False -            break -    if flg: +for i in range(a, b + 1): +    s = str(i) +    if s[0] == s[4] and s[1] == s[3]: