let calc s e =
  let rec aux i c =
    if i < s || e < i then c
    else if i / 10000 <> i mod 10 then aux (i + 1) c
    else
      let i2 = i / 10 mod 1000 in
      if i2 / 100 <> i2 mod 10 then aux (i + 1) c else aux (i + 1) (c + 1)
  in
  aux s 0

let () = Scanf.scanf "%d %d" calc |> Printf.printf "%d\n"
