
c :: Int -> Int -> Int -> Int
c 0 _ _ = 0
c n i j = c (n-1) i j + if [(head . show) n] == show i && mod n 10 == j then 1 else 0


func :: Int -> Int
func n = f n 9 9
  where
  f :: Int -> Int -> Int -> Int
  f n 0 0 = (c n 0 0) * (c n 0 0) + 0
  f n i 0 = (c n 0 i) * (c n i 0) + f n (i-1) 9
  f n i j = (c n j i) * (c n i j) + f n i (j-1)


main = do
  ni <- getLine
  let n = read ni :: Int
  putStrLn $ show (func n)
