let is_palindrome s =
  let len = String.length s in
  let rec aux i j =
    if j < i then true
    else if s.[i] = s.[j] then aux (i + 1) (j - 1)
    else false
  in
  aux 0 (len - 1)

let inc_str s = int_of_string s + 1 |> string_of_int

let solve start fin =
  let rec aux x sum =
    if x > fin then sum
    else if is_palindrome x then aux (inc_str x) (sum + 1)
    else aux (inc_str x) sum
  in
  aux start 0

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