import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    print $ sum [(cnt i j n) * (cnt j i n) | i <- [1..9], j <- [1..9]]

cnt i j n = length [() | k <- [1..n], digitToInt (head (show k)) == i, digitToInt (last (show k)) == j]