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

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

puts count