(* O(b log b) *)
Scanf.scanf "%d %d" @@ fun a b ->
  let rev n =
    let rec f acc n = if n <= 0 then acc else f (acc * 10 + n mod 10) @@ n / 10 in f 0 n in
  let ans = ref 0 in
  for n = a to b do
    if rev n = n then incr ans
  done;
  Printf.printf "%d\n" !ans