def anagram?(a, b)
  (0..(a.length - 1)).each do |i|
    return false if a.count(a[i]) != b.count(a[i])
  end

  true
end

n = gets.chomp.to_i
s = []
(1..n).each do |i|
  s << gets.chomp.chars
end

cnt = 0
(0..(s.length - 1)).each do |i|
  ((i + 1)..(s.length - 1)).each do |j|
    if anagram?(s[i], s[j])
      cnt += 1
    end
  end
end

puts cnt