(* O(b log b) *)
Scanf.scanf "%d %d" @@ fun a b ->
  let ans = ref 0 in
  for n = a to b do
    let s = string_of_int n in
    if s.[0] = s.[4] && s.[1] = s.[3] then incr ans
  done;
  Printf.printf "%d\n" !ans