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

  implicit none

  integer :: n, i, j, k, old, sum
  character ( len = 1 ) :: tmp
  character ( len = 10 ), dimension ( : ), allocatable :: s
  character ( len = 10 ) :: tmp10

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

  read ( *, * ) n

  allocate ( s ( 1:n ) )
  
  do i = 1, n

     read ( *, '(a10)' ) s ( i )

     do k = 1, 9

        do j = 1, 9

           if ( s(i)(j:j) > s(i)(j+1:j+1) ) then

              tmp = s(i)(j:j)
              s(i)(j:j) = s(i)(j+1:j+1)
              s(i)(j+1:j+1) = tmp
              
           end if

        end do
        
     end do
     
  end do

  do j = 1, n - 1

     do i = 1, n - 1

        if ( s(i) > s(i+1) ) then

           tmp10 = s(i)
           s(i) = s(i+1)
           s(i+1) = tmp10

        end if

     end do

  end do


  old = 1
  sum = 0
  
  do i = 1,n-1

     if ( s(i) /= s(i+1) .or. i == n-1 ) then
        
        sum = sum + ( i - old + 1 ) * ( i - old ) / 2
        
        old = i

     end if

  end do

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