let () = Scanf.scanf "%d\n" @@ fun n ->
  let acc = Array.make_matrix 10 10 0 in
  for i = 1 to n do
    let s = string_of_int i in
    let h = Char.code s.[0] - Char.code '0' in
    let l = Char.code s.[String.length s - 1] - Char.code '0' in
    acc.(h).(l) <- 1 + acc.(h).(l)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left ( + )) 0 @@
  Array.init 10 @@ fun i ->
    Array.init 10 @@ fun j ->
      acc.(i).(j) * acc.(j).(i)
