
program main

  implicit none

  integer:: i, j, k, n, idx, pair
  integer:: counts(1:26)
  character(1):: c
  character(10):: tmp
  character(10), allocatable:: s(:)

  read *, n
  allocate( s(1:n) )

  do i= 1, n
    counts(:)= 0
    do j= 1, 10
      read(*,'(a1)',advance='no') c
      idx= ichar(c) - 96
      counts(idx)= counts(idx) + 1
    end do
    read(*,*)

    idx= 0
    tmp=""
    do j= 1, 26
      c= achar(j+96)
      do k= 1, counts(j)
        idx= idx+1
        tmp(idx:idx)= c
      end do
    end do
    s(i)= tmp
  end do

  pair= 0
  do i= 1, n
    do j= i+1, n
      if( s(i)==s(j) ) pair = pair + 1
    end do
  end do
  print '(i0)', pair

end program main
