N = gets.chomp.to_i
words = N.times.map{gets.chomp.chars.sort.join}.group_by(&:itself)
ans = words.inject(0) do |sum, (str, arr)|
  arr.length == 1 ? sum : sum + (1..(arr.length-1)).inject(&:+)
end
puts ans