import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Map as Map
import Data.List

import Control.Monad
import Control.Monad.State

getInts :: IO [Int]
getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  n <- readLn :: IO Int
  
  let ans = (flip evalState) Map.empty $ do
        forM_ [1..n] $ \x -> do
          let s = show x
          let p = (head s, last s)
          
          res <- (Map.lookup p) <$> get
          
          modify $ case res of
            Just c -> Map.insert p (c+1)
            _ -> Map.insert p 1

        sum . catMaybes <$> do
          forM [1..n] $ \x -> do
            let s = show x
            let p = (last s, head s)

            ret <- (Map.lookup p) <$> get

            return ret
      

  print $ ans
