program kadai
implicit none
integer  ::  n
character(len=10),allocatable  ::  s(:)
character(len=10)  ::  hako
character(len=1)  ::  word(10)
integer  ::  i,j,k
integer  ::  num
integer(8)  ::  ans

read(*,*) n

allocate(s(n))

do i=1,n
    read(*,*) s(i)
end do

do i=1,n
    hako=s(i)
    do j=1,10
        word(j)=hako(j:j)
    end do
    call qsort(word)
    do j=1,10
        hako(j:j)=word(j)
    end do
    s(i)=hako
end do


num=0
call qsort(s)

!do i=1,n
!   write(*,*) s(i)
!end do

i=1
num=0
ans=0
do while (i<n+1)
    j=i+1
    do
        if (s(i)==s(j)) then
            num=num+1
            j=j+1
        else
            exit
        end if
    end do
    ans=ans+(num+1)*(num)/2
    i=j
    num=0
end do

write(*,*) ans





stop
contains

subroutine swap(a,b)
implicit none
character(len=*),intent(inout)  ::  a,b
character(len=10)  ::  c
c=a
a=b
b=c
end subroutine swap

subroutine qsort(x)
implicit none
character(len=*), intent(inout)  ::  x(:)
integer  ::  first,last
first=1
last=size(x)
call q2sort(x,first,last)
return
end subroutine qsort

recursive subroutine q2sort(x,first,last)
implicit none
character(len=*), intent(inout)  ::  x(:)
integer, intent(inout) ::  first,last
integer  ::  fir, las
integer  ::  i,j
character(len=10)  ::  n
n=x((first+last)/2)
i=first
j=last
do
do while (x(i)<n)
i=i+1
end do
do while(x(j)>n)
j=j-1
end do
if (i>j .or. i==j) then
exit
end if
call swap(x(i),x(j))
i=i+1
j=j-1
end do
if (first<i-1) then
las=i-1
call q2sort(x,first,las)
end if
if (last>j+1) then
fir=j+1
call q2sort(x,fir,last)
end if
end subroutine q2sort


end program kadai
