let rec fix f x = f (fix f) x
let () =
  Scanf.scanf "%d" @@ fun n ->
  let ad = Array.init 10 (fun _ -> Array.make 10 0) in
  for i = 1 to n do
    let d = fix (fun f x -> if x < 10 then x else f (x/10)) i in
    ad.(i mod 10).(d) <- ad.(i mod 10).(d) + 1;
  done;

  fix (fun f ans i j ->
    if i > 9 then ans
    else if j > 9 then f ans (i+1) 1
    else f (ans + ad.(i).(j) * ad.(j).(i)) i (j+1)) 0 1 1 
  |> Printf.printf "%d\n"
