# Your code here!
n = gets.to_i
a = []

n.times do 
  a << gets.chomp.chars.sort.join("")
end

count = Hash.new(0)
a.each do |elem|
  count[elem] += 1
end

cnt = 0
count.values.each do |i|
    if i >= 2
        cnt += (i * (i - 1)) / 2
    end
end

p cnt