program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,j,n,ans
    character(10),allocatable:: s(:)
    character(1):: tmp
    logical:: ok

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

    do i=1,n
        ok=.false.
        do while(.not. ok)
            ok = .true.
            do j=1,9
                if (s(i)(j:j) > s(i)(j+1:j+1)) then
                    ok = .false.
                    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

    call char_sort(s,1,n)
    j=1
    do i=1,n-1
        if (s(i) == s(i+1)) then
            ans=ans+j
            j=j+1
        else
            j=1
        end if
    end do

    print'(i0)', ans
contains
    recursive subroutine char_sort(c,fst,lst)
        integer(int32),intent(in):: fst, lst
        character(*),intent(inout):: c(:)
        integer(int32):: mdl

        if (lst-fst < 2)then
            if (c(fst) > c(lst)) call cswap(c(fst),c(lst))
            return
        end if

        mdl = (fst+lst)/2
        call char_sort(c,fst,mdl)
        call char_sort(c,mdl+1,lst)
        call char_merge(c,fst,mdl,lst)
    end subroutine

    subroutine char_merge(c,fst,mdl,lst)
        integer(int32),intent(in):: fst,mdl,lst
        character(*),intent(inout):: c(:)
        character(:),allocatable:: tmp(:)
        integer(int32):: l,r,ti

        allocate(character(len(c(1))):: tmp(lst-fst+1))
        l=fst
        r=mdl+1
        ti=1

        do while(l <= mdl .and. r <= lst)
            if (c(l) <= c(r)) then
                tmp(ti) = c(l)
                l=l+1
            else
                tmp(ti) = c(r)
                r=r+1
            end if
            ti=ti+1
        end do

        if (l <= mdl) then
            tmp(ti:) = c(l:mdl)
        else
            tmp(ti:) = c(r:lst)
        end if

        c(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine cswap(c1,c2)
        character(*):: c1,c2
        character(:),allocatable:: tmp
        allocate(character(len(c1)):: tmp)

        tmp = c1
        c1 = c2
        c2 = tmp
    end subroutine
end program name