isP :: Int -> Bool
isP i = case cs of 
  (a:b:c:d:e) -> a == (head e) && b == d
  otherwise -> False
  where 
    cs = [[c] | c <- show i]

main = do
  n <- fmap (read :: String -> Int) . words <$> getLine
  let l = head n
  let r = last n
  putStrLn $ show $ length $ filter isP [l .. r]