-- 投了です動きません
readInt :: String -> Int
readInt str = read str :: Int
 
main = map readInt.words<$>getLine >>=print.solve

solve (a:b:[]) = length [x | x <- [1 .. ] , a<=x , x<=b ,x == (paliner x) ]

paliner a = (ketaflip a 0) +(ketaflip a 1) +(ketaflip a 2) + (ketaflip a 3 ) + (ketaflip a 4) 

ketaflip a b = (div (mod a 10^(b+1)) 10^b )*10^(4-b) 