let rec for_iter f a b = if a > b then [] else let x = f a in x :: for_iter f (a+1) b
let () =
  Scanf.scanf "%d %d" (for_iter @@ fun i ->
    let s = string_of_int i in
    if s.[0] = s.[4] && s.[1] = s.[3] then 1 else 0)
  |> List.fold_left (+) 0 |> Printf.printf "%d\n"