n = STDIN.gets.chomp.to_i
s = []
n.times { |i| s.push(STDIN.gets.chomp.split('').sort.join) }
s.sort!

result = 0
(0...n).each do |i|
  tmp = s.shift
  result += s.select {|item| item == s[i]}.length
end

puts result