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

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

main = do
  n <- getInt
  print $ solve n
  where
    solve n = solve' 0 1 n
    solve' ans i n | i > n = ans
                   | otherwise =
                     let c = countB i n
                     in
                       solve' (ans + c) (i + 1) n
    countB a n =
      let s = show a
          ah = read [head s] :: Int
          al = read [last s] :: Int
          c1 = if ah == al then 1 else 0
          c2 = if al /= 0 && al*10+ah <= n then 1 else 0
      in
        c1 + c2
        + countB' 100 al ah n
        + countB' 1000 al ah n
        + countB' 10000 al ah n
        + countB' 100000 al ah n

    countB' x al ah n | al == 0 = 0
                      | otherwise =
                        let
                          m = al * x + ah
                          d = n - m
                          c1 = x `div` 10
                          c2 = d `div` 10 + 1
                        in if d < 0
                           then 0
                           else min c1 c2