program main
integer,allocatable :: a(:,:)
integer :: tmp(10)
character,allocatable :: s(:)
integer :: n,i,j,ans = 0

read *,n
allocate(a(n,10),s(n))
read *,s

do i = 1,n
do j = 1,10
a(i,j) = ichar(s(i)(j:j))
end do
end do

do i = 1,n
call quicksort(a(i,:),1,10)
end do

do i = 1,n-1
do j = i+1, n
tmp = abs(a(i,:) - a(j,:))
print *,tmp
if (maxval(tmp) == 0) ans = ans +1
end do
end do

print *,ans

contains
recursive subroutine quicksort(a, first, last)
  implicit none
  integer :: a(*)
  integer first, last
  integer i, j
  real*8  x, t
  
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
end subroutine quicksort
end program