n = gets.to_i
i = 0
re = 0
hash = {}
while i < n do 
  s = gets.chomp.chars.sort.join
  if hash.value?(s) 
    re += hash.values.count(s)
    hash[i] = s
  else
    hash[i] = s
  end
  p hash
  i += 1
end
p re