open System
open System.Linq

#nowarn "25"

let inline readLine _ = stdin.ReadLine()
let inline readInt<'a> = readLine >> int
let inline readLong<'a> = readLine >> int64
let inline readFloat<'a> = readLine >> float
let inline readArray _ = readLine().Split ' '
let inline readArrayInt _ = readArray() |> Array.map (int)
let inline charToInt ch = int ch - int '0'

let n = readInt()
let cnt = Array2D.zeroCreate<Int64> 10 10
for i in 1..n do
    let head = (i
        |> string
        |> Enumerable.First
        |> charToInt)
    let tail = i % 10
    cnt.[head, tail] <- cnt.[head, tail] + 1L
Seq.init 10 (fun i ->
    Seq.init 10 (fun j ->
        cnt.[i, j] * cnt.[j, i]))
|> Seq.sumBy (Seq.sum)
|> printfn "%d"
