!!!**********************************************************************
program main
!!!**********************************************************************

  implicit none

  integer :: n, i, j, k, t, sum
  integer, dimension ( 1:10 ) :: tmp      
  character ( len = 10 ), allocatable, dimension ( : ) :: s
  character ( len = 1 ) :: p
  character ( len = 1 ), dimension ( 1:26 ), parameter :: alph = (/   'a', 'b', 'c', 'd', &
       &  'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', &
       &  'u', 'v', 'w', 'x', 'y', 'z' /)

!!!----------------------------------------------------------------------

  read ( *, * ) n

  allocate ( s ( 1:n ) )

  do i = 1, n

     read ( unit = *, fmt = '(a10)' ) s ( i )

     do j = 1, 10

        do k = 1, 26

        if ( s ( i ) ( j:j ) .eq. alph ( k ) ) then

           tmp ( j ) = k

        end if

     end do

     end do

     do j = 1, 10

        do k = 1, 10

           if ( tmp ( k + 1 ) < tmp ( k ) ) then

              t = tmp ( k + 1 )

              p = s ( i ) ( k+1:k+1 )
              
              tmp ( k + 1 ) = tmp ( k )

              s ( i ) ( k+1:k+1 ) = s ( i ) ( k:k )

              tmp ( k ) = t

              s ( i ) ( k:k ) = p

           end if

        end do

     end do

  end do

  sum = 0
  
  do i = 1, n

     do j = i + 1, n

        if ( s ( i ) .eq. s ( j) ) then

           sum = sum + 1
           
        end if
           
     end do

  end do

  write ( unit = *, fmt = '(i0)' ) sum
  
!!!**********************************************************************  
end program main
!!!**********************************************************************
