program green_bin
  implicit none
  integer :: n, i, j
  character(10) :: s(100001) = ""
  integer(8) :: ans = 0_8, m
  read(*,*) n
  do i = 1, n
    read(*,*) s(i)
    call bubble_sort(s(i))
  end do
  call quick_sort(s(1:n))
  i = 1
  do while (i <= n)
    j = i
    do
      if (s(i) /= s(j)) then
        m = int(j-i,8)
        ans = ans+m*(m-1_8)/2_8
        i = j
        exit
      end if
      j = j+1
    end do
  end do
  write(*,'(i0)') ans
contains
  subroutine bubble_sort(s)
    character(*) :: s
    character(1) :: t
    integer :: i, j, n
    n = len_trim(s)
    do i = 1, n-1
      do j = 2, n-i+1
        if (s(j-1:j-1) > s(j:j)) then
          t = s(j-1:j-1)
          s(j-1:j-1) = s(j:j)
          s(j:j) = t
        end if
      end do
    end do
  end
  recursive subroutine quick_sort(a)
    character(*), intent(inout) :: a(:)
    character(10) :: p, c
    integer :: n, l, r
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l > 2) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program green_bin