program main
      implicit none
      integer :: n
      integer :: i, j, k
      integer(8) :: cnt
      integer :: numa(1:9,1:9), numb(1:9,1:9)

      read *, n

      numa = 0
      numb = 0
      do i = 1, n
         if ( i < 10 ) then
           j = i
           k = i
         else
           j = i
           do while ( j > 9 )
             j = j/10
           end do
           k = mod(i,10)
         end if
         if ( k == 0 ) cycle
         numa(j,k) = numa(j,k) + 1
         numb(k,j) = numb(k,j) + 1
      end do

      cnt = 0
      do i = 1, 9
        do j = 1, 9
          cnt = cnt + numa(i,j)*numb(i,j)
        end do
      end do

      print *, cnt

end program main
