open System 
open System.Text

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): 'a = LanguagePrimitives.GenericZero
    let inline FromOne(): 'a = LanguagePrimitives.GenericOne
    let inline FromInt32 (n: int): 'a = fromInt n

let R() = Console.ReadLine()



let f (x: int): int =
    let g n = let t = string n in t.[0], t.[t.Length - 1]
    let g' n = let t = string n in t.[t.Length - 1], t.[0]
    let m = 
        [ for i in 1 .. x do g i ]
        |> List.groupBy id 
        |> List.map (fun (k, v) -> k, List.length v)
        |> Map.ofList
    [ for i in 1 .. x do g' i ]
    |> List.sumBy(fun t -> 
        match Map.tryFind t m with 
        | Some v -> v 
        | _ -> 0)

let N = int <| R()

f N 
|> printfn "%i"