isPalindromic :: Int -> Int -> Bool
isPalindromic 0 _ = True
isPalindromic d n
  | q == r = isPalindromic (d `div` 100) ((n `mod` d) `div` 10)
  | otherwise = False
  where
    q = n `div` d
    r = n `mod` 10

main = do
  line <- getLine
  let
    [a,b] = map read $ words line :: [Int]
    ans = length $ filter (\x -> x == True) $ map (isPalindromic 10000) [a .. b]
  putStrLn $ show ans
