N = gets.to_i

set = Hash.new {|h,k| h[k] = 0}
count = 0
while gets
  string = $_.chomp.chars.sort.join
  if set.key?(string)
    count += set[string]
    set[string] += 1
  else
    set[string] += 1
  end
end

puts count
