n=gets.chomp.to_i
count=0
a=[]
b=[]
k=0
for i in 1..n
  a<< gets.chomp
end

for i in 0..(n-1)
  for m in (i+1)..(n-1)
    b=a[m].split("").uniq
    while k<=b.length-1
      if a[m].count(b[k])!=a[i].count(b[k])
        break
      end
      k+=1
    end
    count += 1 if k==b.length
    k=0
  end
end
puts count