def green_bin(s)
  s.map! { |str| str.chars.sort.join }
  count = Hash.new(0)
  s.each { |str| count[str] += 1 }

  ans = 0
  count.each_value do |c|
    next if c == 1
    ans += c * (c - 1) / 2
  end
  ans
end

n = gets.to_i
s = []
n.times{ s << gets.chomp }

puts green_bin(s);
