import qualified Data.Map.Strict as M
import Data.Maybe

main = do
    n <- readLn :: IO Int
    let ab = M.fromListWith (+) $ map ((\s -> ((head s, last s),1)) . show) [1..n]
        ans = [(fromMaybe 0 (M.lookup (i, j) ab)) * (fromMaybe 0 (M.lookup (j, i) ab))| i <- ['1'..'9'], j <- ['1'..'9']]
    print $ sum ans