import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  let
    f :: Int -> Int
    f k = 10 * g k + (k `mod` 10)
    g :: Int -> Int
    g k | k < 10    = k
        | otherwise = g (k `div` 10)
    encode :: Int -> Int -> Int
    encode i j = 10 * i + j
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    counts = VU.accum (const . succ) (VU.replicate 100 0) . map (flip (,) () . f) $ [1..n] :: VU.Vector Int
    op :: Int -> Int -> Int
    op i j = counts VU.! encode i j * counts VU.! encode j i
  print . sum $ op <$> [0..9] <*> [0..9]

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
