      module piyo
      implicit none
      
      contains
      
      function getRight( i ) result( res )
        implicit none
        integer(16) :: i,res
        res = i - (i/10)*10
      end function
      
      function getLeft( i ) result( res )
        implicit none
        integer(16) :: i,res,k,next
        k = 10
        res = i
        do while( .true. )
          
          next = res / 10
          if( next == 0 ) exit
          res = next
          k = k * 10
        end do
      end function
      
      end module piyo
      
      PROGRAM handstand2
      use piyo
      IMPLICIT NONE
      integer(16) :: n,ans
      integer(16) :: a,b,ar,al,br,bl
      
      read*,n
      
      if( n/10==0 )then
        print*,n
        stop
      end if
      
      ans = 0
      do a = 1,n-1
      ar = getRight( a )
      al = getLeft( a )
        do b = a+1,n
          br = getRight( b )
          bl = getLeft( b )
          
          if( br==al.and.bl==ar ) ans = ans + 1
          
        end do
      end do
      
      
      
      
      END PROGRAM