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





def kaibun(m, n):

	key = 0

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

		if str(i) == str(i)[::-1]:

			key += 1

	return key



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

 

def kaibun(m, n):

    key = 0

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

        s = i//10000  

        t = i%10

        u = i//1000 % 10

        v = i//10 % 10

        if (s==t)&(u==v):

            key += 1

    return key

 

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


def kaibun(m, n):
    key = 0
    for i in range(m, n + 1):
        if str(i) == str(i)[::-1]:
            key += 1
    return key


print((kaibun(A, B)))

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


def kaibun(m, n):
    key = 0
    for i in range(m, n + 1):
        s = i // 10000
        t = i % 10
        u = i // 1000 % 10
        v = i // 10 % 10
        if (s == t) & (u == v):
            key += 1
    return key


print((kaibun(A, B)))

-        if str(i) == str(i)[::-1]: +        s = i // 10000 +        t = i % 10 +        u = i // 1000 % 10 +        v = i // 10 % 10 +        if (s == t) & (u == v):