lines = readlines
n = lines[0].chomp.to_i

arr = []
for i in 1..n do
  arr << lines[i].chomp.chars.sort.join
end

count_hash = Hash.new(0)

arr.each do |a|
  count_hash[a] += 1
end

result = 0
count_hash.each_value do |culc|
  result += culc*(culc-1) / 2
end

p result