n = gets.chomp.to_i
ana = []
n.times do |i|
  ana << gets.chomp.chars.sort(&:casecmp).join
end
idx = []
ana.group_by(&:itself).select{|k, v| v.size > 1 }.map(&:first).each do |a|
  idx << ana.map.with_index { |e,i| e == a ? i : nil }.compact.combination(2).to_a.count
end
puts idx.inject(&:+)