implicit none
integer, allocatable :: hist(:,:)
integer :: n,i,j,ans
character(10) :: s
integer :: d(26)

read *,n
allocate(hist(26,n))
hist(:,:) = 0
do i = 1,n
   read *,s
   do j = 1, 10
      if (s(j:j) == 'a') then 
      hist(1,i) = hist(1,i) + 1
      else if (s(j:j) == 'b') then 
      hist(2,i) = hist(2,i) + 1
      else if (s(j:j) == 'c') then 
      hist(3,i) = hist(3,i) + 1
      else if (s(j:j) == 'd') then 
      hist(4,i) = hist(4,i) + 1
      else if (s(j:j) == 'e') then 
      hist(5,i) = hist(5,i) + 1
      else if (s(j:j) == 'f') then 
      hist(6,i) = hist(6,i) + 1
      else if (s(j:j) == 'g') then 
      hist(7,i) = hist(7,i) + 1
      else if (s(j:j) == 'h') then 
      hist(8,i) = hist(8,i) + 1
      else if (s(j:j) == 'i') then 
      hist(9,i) = hist(9,i) + 1
      else if (s(j:j) == 'j') then 
      hist(10,i) =hist(10,i) + 1
      else if (s(j:j) == 'k') then 
      hist(11,i) =hist(11,i) + 1
      else if (s(j:j) == 'l') then 
      hist(12,i) =hist(12,i) + 1
      else if (s(j:j) == 'm') then 
      hist(13,i) =hist(13,i) + 1
      else if (s(j:j) == 'n') then 
      hist(14,i) =hist(14,i) + 1
      else if (s(j:j) == 'o') then 
      hist(15,i) =hist(15,i) + 1
      else if (s(j:j) == 'p') then 
      hist(16,i) =hist(16,i) + 1
      else if (s(j:j) == 'q') then 
      hist(17,i) =hist(17,i) + 1
      else if (s(j:j) == 'r') then 
      hist(18,i) =hist(18,i) + 1
      else if (s(j:j) == 's') then 
      hist(19,i) =hist(19,i) + 1
      else if (s(j:j) == 't') then 
      hist(20,i) =hist(20,i) + 1
      else if (s(j:j) == 'u') then 
      hist(21,i) =hist(21,i) + 1
      else if (s(j:j) == 'v') then 
      hist(22,i) =hist(22,i) + 1
      else if (s(j:j) == 'w') then 
      hist(23,i) =hist(23,i) + 1
      else if (s(j:j) == 'x') then 
      hist(24,i) =hist(24,i) + 1
      else if (s(j:j) == 'y') then 
      hist(25,i) =hist(25,i) + 1
      else if (s(j:j) == 'z') then 
      hist(26,i) =hist(26,i) + 1
      endif
   enddo
enddo

ans = 0
do i = 1, n-1
   do j = i+1, n
      d = hist(:,i) - hist(:,j)
      if (minval(d) /=0) cycle
      if (maxval(d) /= 0) cycle
      ans = ans + 1
   enddo
enddo

print '(i0)',ans
end